Move loadUser error handling to the function itself

This commit is contained in:
Maciej Pędzich 2023-05-26 15:01:35 +02:00
parent bf18b7c4c7
commit f8465276e3
2 changed files with 7 additions and 7 deletions

View File

@ -29,6 +29,12 @@ export function useAuth() {
const currentUser = await account.get(); const currentUser = await account.get();
user.value = currentUser; user.value = currentUser;
} catch (error) {
if (import.meta.env.DEV) {
console.error(error);
}
user.value = null;
} finally { } finally {
loadingUserFinished.value = true; loadingUserFinished.value = true;
} }

View File

@ -8,13 +8,7 @@ export async function authGuard(
) { ) {
const { isLoggedIn, loadUser } = useAuth(); const { isLoggedIn, loadUser } = useAuth();
try { await loadUser();
await loadUser();
} catch (error) {
if (import.meta.env.DEV) {
console.error(error);
}
}
if (!to.meta.authRequired || isLoggedIn.value) { if (!to.meta.authRequired || isLoggedIn.value) {
return next(); return next();