diff --git a/gymboard-app/src/api/main/auth.ts b/gymboard-app/src/api/main/auth.ts index 141f80a..6343393 100644 --- a/gymboard-app/src/api/main/auth.ts +++ b/gymboard-app/src/api/main/auth.ts @@ -1,6 +1,5 @@ import { api } from 'src/api/main/index'; import {AuthStoreType} from 'stores/auth-store'; -import Timeout = NodeJS.Timeout; import { WeightUnit } from 'src/api/main/submission'; import {Page, PaginationOptions, toQueryParams} from 'src/api/main/models'; @@ -67,41 +66,6 @@ export enum UserFollowResponse { } class AuthModule { - private static readonly TOKEN_REFRESH_INTERVAL_MS = 30000; - - private tokenRefreshTimer?: Timeout; - - /** - * Attempts to use the given credentials to obtain an access token for - * sending authenticated requests. - * @param authStore The auth store to use to update app state. - * @param credentials The credentials for logging in. - */ - public async login(authStore: AuthStoreType, credentials: TokenCredentials) { - authStore.token = await this.getNewToken(credentials); - authStore.user = await this.getMyUser(authStore); - // Load the user's attached data right away too. - const [personalDetails, preferences, roles] = await Promise.all([ - this.getMyPersonalDetails(authStore), - this.getMyPreferences(authStore), - this.getMyRoles(authStore) - ]); - authStore.user.personalDetails = personalDetails; - authStore.user.preferences = preferences; - authStore.roles = roles; - - clearTimeout(this.tokenRefreshTimer); - this.tokenRefreshTimer = setInterval( - () => this.refreshToken(authStore), - AuthModule.TOKEN_REFRESH_INTERVAL_MS - ); - } - - public logout(authStore: AuthStoreType) { - authStore.logOut(); - clearTimeout(this.tokenRefreshTimer); - } - public async register(payload: UserCreationPayload): Promise { const response = await api.post('/auth/register', payload); return response.data; @@ -117,18 +81,9 @@ class AuthModule { return response.data.token; } - public async refreshToken(authStore: AuthStoreType) { - try { - const response = await api.get('/auth/token', authStore.axiosConfig); - authStore.token = response.data.token; - } catch (error: any) { - authStore.logOut(); - if (error.response) { - console.warn('Failed to refresh token: ', error.response); - } else { - console.error(error); - } - } + public async refreshToken(authStore: AuthStoreType): Promise { + const response = await api.get('/auth/token', authStore.axiosConfig); + return response.data.token; } public async getMyUser(authStore: AuthStoreType): Promise { diff --git a/gymboard-app/src/components/AccountMenuItem.vue b/gymboard-app/src/components/AccountMenuItem.vue index a3e551b..24b407e 100644 --- a/gymboard-app/src/components/AccountMenuItem.vue +++ b/gymboard-app/src/components/AccountMenuItem.vue @@ -22,7 +22,7 @@ account-related actions. {{ $t('accountMenuItem.settings') }} - + {{ $t('accountMenuItem.logOut') }} @@ -42,7 +42,6 @@ account-related actions. diff --git a/gymboard-app/src/leaflet.d.js.ts b/gymboard-app/src/leaflet.d.js.ts index b745891..23aa587 100644 --- a/gymboard-app/src/leaflet.d.js.ts +++ b/gymboard-app/src/leaflet.d.js.ts @@ -1,3 +1,6 @@ +/** + * Module declaration for the "leaflet" library for showing openstreetmap content. + */ declare module 'leaflet'; export {}; diff --git a/gymboard-app/src/pages/auth/LoginPage.vue b/gymboard-app/src/pages/auth/LoginPage.vue index d3f428c..cae2d75 100644 --- a/gymboard-app/src/pages/auth/LoginPage.vue +++ b/gymboard-app/src/pages/auth/LoginPage.vue @@ -55,19 +55,17 @@