Add beginning of Google Auth

This commit is contained in:
2023-11-18 00:49:06 -05:00
parent f2d4ce12d4
commit 7b70c13f3f
11 changed files with 599 additions and 13 deletions

View File

@@ -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 };
});