show user data based on authorization?

Hello, I understand how I want to log users in and persist login state with localstorage but how would one show the data that is specific to them? Would every component have to render items based on a get request to the database?
1 Reply
Bersaelor
Bersaelor2y ago
I mean, it depends on what you want to do exactly, I have an application where I have one plain ts file with a:
const [isAuthenticated, setIsAuthenticated] = createSignal(false);
const [user, setUser] = createSignal<CognitoUser | undefined>(undefined);

export {
isAuthenticated,
user,
};
const [isAuthenticated, setIsAuthenticated] = createSignal(false);
const [user, setUser] = createSignal<CognitoUser | undefined>(undefined);

export {
isAuthenticated,
user,
};
This signal isn't part of any component but imported into all the components that need to know if a user is authenticated or not.
Want results from more Discord servers?
Add your server