diff --git a/src/helpers/redirectToProvider.ts b/src/helpers/redirectToProvider.ts index 1253b065d..fec8a1eb9 100644 --- a/src/helpers/redirectToProvider.ts +++ b/src/helpers/redirectToProvider.ts @@ -1,14 +1,9 @@ -import {createRandomID} from '@/helpers/randomId' import {parseURL} from 'ufo' -export interface Provider { - name: string - key: string - authUrl: string - clientId: string -} +import {createRandomID} from '@/helpers/randomId' +import type {IProvider} from '@/types/IProvider' -export const redirectToProvider = (provider: Provider, redirectUrl: string = '') => { +export const redirectToProvider = (provider: IProvider, redirectUrl: string = '') => { // We're not using the redirect url provided by the server to allow redirects when using the electron app. // The implications are not quite clear yet hence the logic to pass in another redirect url still exists. diff --git a/src/stores/auth.ts b/src/stores/auth.ts index 61eda3284..ace2e4d51 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -275,6 +275,27 @@ export const useAuthStore = defineStore('auth', { } }, + /** + * Try to verify the email + * @returns {Promise} if the email was successfully confirmed + */ + async verifyEmail() { + const emailVerifyToken = localStorage.getItem('emailConfirmToken') + if (emailVerifyToken) { + const stopLoading = setModuleLoading(this) + try { + await HTTPFactory().post('user/confirm', {token: emailVerifyToken}) + localStorage.removeItem('emailConfirmToken') + return true + } catch(e) { + throw new Error(e.response.data.message) + } finally { + stopLoading() + } + } + return false + }, + async saveUserSettings({ settings, showMessage = true, diff --git a/src/stores/base.ts b/src/stores/base.ts index 9c07cdd8d..2e5702b6c 100644 --- a/src/stores/base.ts +++ b/src/stores/base.ts @@ -132,7 +132,7 @@ export const useBaseStore = defineStore('base', { async loadApp() { await checkAndSetApiUrl(window.API_URL) - await useAuthStore().checkAuth() + useAuthStore().checkAuth() }, }, }) diff --git a/src/stores/config.ts b/src/stores/config.ts index b36b743ac..58e23aa77 100644 --- a/src/stores/config.ts +++ b/src/stores/config.ts @@ -4,6 +4,8 @@ import {parseURL} from 'ufo' import {HTTPFactory} from '@/http-common' import {objectToCamelCase} from '@/helpers/case' +import type {IProvider} from '@/types/IProvider' + export interface ConfigState { version: string, frontendUrl: string, @@ -29,7 +31,7 @@ export interface ConfigState { openidConnect: { enabled: boolean, redirectUrl: string, - providers: [], + providers: IProvider[], }, }, } diff --git a/src/types/IProvider.ts b/src/types/IProvider.ts new file mode 100644 index 000000000..b70c1af1c --- /dev/null +++ b/src/types/IProvider.ts @@ -0,0 +1,6 @@ +export interface IProvider { + name: string; + key: string; + authUrl: string; + clientId: string; +} diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue index e855c5f7c..133604848 100644 --- a/src/views/user/Login.vue +++ b/src/views/user/Login.vue @@ -14,14 +14,14 @@ class="input" id="username" name="username" :placeholder="$t('user.auth.usernamePlaceholder')" - ref="username" + ref="usernameRef" required type="text" autocomplete="username" v-focus @keyup.enter="submit" tabindex="1" - @focusout="validateField('username')" + @focusout="validateUsernameField()" />

@@ -39,7 +39,7 @@ {{ $t('user.auth.forgotPassword') }} - +

@@ -101,136 +101,112 @@
-