diff --git a/src/localization/en.json b/src/localization/en.json index f169bac0..28694048 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -2229,6 +2229,18 @@ }, "message": { "auto_login_delay_countdown": "Auto-login in {seconds}s...", + "auth": { + "login_greeting": "Hello there, {name}!", + "logout_greeting": "See you again, {name}!", + "email_2fa_resent": "Email 2FA resent.", + "email_2fa_no_credentials": "Cannot send 2FA email without saved credentials. Please login again.", + "incorrect_primary_password": "Incorrect primary password", + "saved_credentials_invalid": "Saved credentials are no longer valid.", + "account_removed": "Account removed.", + "auto_login_success": "Automatically logged in.", + "auto_login_failed": "Failed to login automatically.", + "offline": "You're offline." + }, "vrcx_updater": { "failed": "Failed to check for update, {message}", "failed_install": "Failed to install update", diff --git a/src/stores/auth.js b/src/stores/auth.js index 7bb70bbb..7f27048b 100644 --- a/src/stores/auth.js +++ b/src/stores/auth.js @@ -78,9 +78,9 @@ export const useAuthStore = defineStore('Auth', () => { updateStoredUser(currentUser); new Noty({ type: 'success', - text: `Hello there, ${escapeTag( - currentUser.displayName - )}!` + text: t('message.auth.login_greeting', { + name: `${escapeTag(currentUser.displayName)}` + }) }).show(); } }, @@ -155,9 +155,9 @@ export const useAuthStore = defineStore('Auth', () => { if (watchState.isLoggedIn) { new Noty({ type: 'success', - text: `See you again, ${escapeTag( - userStore.currentUser.displayName - )}!` + text: t('message.auth.logout_greeting', { + name: `${escapeTag(userStore.currentUser.displayName)}` + }) }).show(); } userStore.userDialog.visible = false; @@ -238,7 +238,7 @@ export const useAuthStore = defineStore('Auth', () => { relogin(user).then(() => { new Noty({ type: 'success', - text: 'Email 2FA resent.' + text: t('message.auth.email_2fa_resent') }).show(); }); return; @@ -246,7 +246,7 @@ export const useAuthStore = defineStore('Auth', () => { } new Noty({ type: 'error', - text: 'Cannot send 2FA email without saved credentials. Please login again.' + text: t('message.auth.email_2fa_no_credentials') }).show(); } @@ -462,7 +462,7 @@ export const useAuthStore = defineStore('Auth', () => { try { password = await checkPrimaryPassword(loginParams); } catch (err) { - toast.error('Incorrect primary password'); + toast.error(t('message.auth.incorrect_primary_password')); throw err; } } @@ -481,7 +481,7 @@ export const useAuthStore = defineStore('Auth', () => { } } catch (err) { if (err.message.includes('Invalid Username/Email or Password')) { - toast.error('Saved credentials are no longer valid.'); + toast.error(t('message.auth.saved_credentials_invalid')); await deleteSavedLogin(user.user.id); } throw err; @@ -506,7 +506,7 @@ export const useAuthStore = defineStore('Auth', () => { ); new Noty({ type: 'success', - text: 'Account removed.' + text: t('message.auth.account_removed') }).show(); } @@ -824,7 +824,7 @@ export const useAuthStore = defineStore('Auth', () => { } AppDebug.errorNoty = new Noty({ type: 'success', - text: 'Automatically logged in.' + text: t('message.auth.auto_login_success') }).show(); console.log('Automatically logged in.'); }) @@ -834,15 +834,16 @@ export const useAuthStore = defineStore('Auth', () => { } AppDebug.errorNoty = new Noty({ type: 'error', - text: 'Failed to login automatically.' + text: t('message.auth.auto_login_failed') }).show(); console.error('Failed to login automatically.', err); }) .finally(() => { + attemptingAutoLogin.value = false; if (!navigator.onLine) { AppDebug.errorNoty = new Noty({ type: 'error', - text: `You're offline.` + text: t('message.auth.offline') }).show(); console.error(`You're offline.`); }