feat: (auth) switch to OTP code via e-mail
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m24s

This commit is contained in:
2024-06-14 16:23:48 -04:00
parent 1526a10630
commit 643d74e29d
3 changed files with 89 additions and 22 deletions

View File

@@ -45,22 +45,31 @@ export const useAuthStore = defineStore('auth', () => {
await init();
}
async function createTokenSession(email: string) {
return await account.createEmailToken(ID.unique(), email);
}
async function googleLogin() {
account.createOAuth2Session(
await account.createOAuth2Session(
OAuthProvider.Google,
'https://oys.undock.ca',
'https://oys.undock.ca/login'
);
currentUser.value = await account.get();
await init();
}
async function discordLogin() {
account.createOAuth2Session(
await account.createOAuth2Session(
OAuthProvider.Discord,
'https://oys.undock.ca',
'https://oys.undock.ca/login'
);
currentUser.value = await account.get();
await init();
}
async function tokenLogin(userId: string, token: string) {
await account.createSession(userId, token);
await init();
}
function getUserNameById(id: string | undefined | null): string {
@@ -102,6 +111,8 @@ export const useAuthStore = defineStore('auth', () => {
login,
googleLogin,
discordLogin,
createTokenSession,
tokenLogin,
logout,
init,
};