Hey, Im pretty new to coding and am currently working on a school competition project.
This is my code for a login. It does work as intended, but now I want to show content on my dashboard based on the users role.
import { load } from '../../(dashboard)/dashboard/+layout';
let email = '';
let password = '';
let loggedInUser = null;
const users = load();
function login() {
loggedInUser = Object.values(users).find(user => user.email === email && user.password === password);
if (loggedInUser) {
navigate('/dashboard');
console.log(loggedInUser);
} else {
alert('Invalid email or password');
}
}```
And this is one of my user Objects.
``` 'User1': {
firstname: 'John',
lastname: 'Doe',
email: '[email protected]',
password: 'userpassword',
username: 'johndoe',
role: 'User',
FSAW: 5,
FSW: 10,
FSM: 33,
FSY: 325,
wochenstunden: 36,
FSWP: 10 / 50,
},```
However, after importing the "loggedInUser" variable from my login page which basically stores the logged in user, I cant call its role
As I get an error "Property 'role' does not exist on type 'typeof Page__SvelteComponent_'. ts(2339). I need help to be able to call the role property
```{#if loggedInUser && loggedInUser.role === "Admin"}```
I've tried fixing this for hours now and cant seem to get any closer
I hope the information I provided is helpful enough