mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Assign user to userStore
This commit is contained in:
parent
84375a582e
commit
7bf12cc552
@ -42,9 +42,11 @@ export default function LoginForm() {
|
||||
});
|
||||
|
||||
if (ok) {
|
||||
setItem(AUTH_TOKEN, data.token);
|
||||
const { user, token } = data;
|
||||
|
||||
setUser(data.user);
|
||||
setItem(AUTH_TOKEN, token);
|
||||
|
||||
setUser(user);
|
||||
|
||||
await router.push('/');
|
||||
|
||||
|
@ -12,14 +12,17 @@ export default function useRequireLogin() {
|
||||
async function loadUser() {
|
||||
setLoading(true);
|
||||
|
||||
const { ok, data } = await get('/auth/verify');
|
||||
const {
|
||||
ok,
|
||||
data: { user },
|
||||
} = await get('/auth/verify');
|
||||
|
||||
if (!ok) {
|
||||
await router.push('/login');
|
||||
return null;
|
||||
}
|
||||
|
||||
setUser(data);
|
||||
setUser(user);
|
||||
|
||||
setLoading(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user