Add beginning of Google Auth
This commit is contained in:
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
|
||||
import { ID, account } from 'boot/appwrite';
|
||||
import type { Models } from 'appwrite';
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
const currentUser = ref<Models.User<Models.Preferences> | null>(null);
|
||||
@@ -24,10 +25,18 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
await account.createEmailSession(email, password);
|
||||
currentUser.value = await account.get();
|
||||
}
|
||||
async function googleLogin() {
|
||||
account.createOAuth2Session(
|
||||
'google',
|
||||
'https://bab.toal.ca/',
|
||||
'https://bab.toal.ca/#/login'
|
||||
);
|
||||
currentUser.value = await account.get();
|
||||
}
|
||||
|
||||
function logout() {
|
||||
return account.deleteSession('current').then((currentUser.value = null));
|
||||
}
|
||||
|
||||
return { currentUser, register, login, logout, init, ready };
|
||||
return { currentUser, register, login, googleLogin, logout, init, ready };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user