mirror of
https://github.com/maciejpedzich/racemash.git
synced 2024-11-27 16:15:47 +01:00
Rename userLoadingFinished to loadingUserFinished
This commit is contained in:
parent
d0207363bf
commit
ad0558d7cb
@ -4,7 +4,7 @@ import { Models } from 'appwrite';
|
|||||||
import { account } from '@/appwrite';
|
import { account } from '@/appwrite';
|
||||||
|
|
||||||
const user = ref<Models.User<Models.Preferences> | null>(null);
|
const user = ref<Models.User<Models.Preferences> | null>(null);
|
||||||
const userLoadingFinished = ref(false);
|
const loadingUserFinished = ref(false);
|
||||||
const isLoggedIn = computed(() => !!user.value);
|
const isLoggedIn = computed(() => !!user.value);
|
||||||
|
|
||||||
export function useAuth() {
|
export function useAuth() {
|
||||||
@ -17,24 +17,20 @@ export function useAuth() {
|
|||||||
|
|
||||||
account.createOAuth2Session(
|
account.createOAuth2Session(
|
||||||
provider,
|
provider,
|
||||||
`${location.origin}${redirectPath}`,
|
`${location.origin}${redirectPath}#login-success`,
|
||||||
`${location.origin}/log-in#oauth-error`,
|
`${location.origin}/log-in#login-error`,
|
||||||
permissionScopes
|
permissionScopes
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadUser = async () => {
|
const loadUser = async () => {
|
||||||
try {
|
try {
|
||||||
if (userLoadingFinished.value) return;
|
if (loadingUserFinished.value) return;
|
||||||
|
|
||||||
const currentUser = await account.get();
|
const currentUser = await account.get();
|
||||||
user.value = currentUser;
|
user.value = currentUser;
|
||||||
} catch (error) {
|
|
||||||
// TODO: Add to globaL Vue error logger and implement snackbar message bus
|
|
||||||
console.error(error);
|
|
||||||
user.value = null;
|
|
||||||
} finally {
|
} finally {
|
||||||
userLoadingFinished.value = true;
|
loadingUserFinished.value = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,7 +41,7 @@ export function useAuth() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
userLoadingFinished,
|
loadingUserFinished,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
logIn,
|
logIn,
|
||||||
loadUser,
|
loadUser,
|
||||||
|
Loading…
Reference in New Issue
Block a user