diff --git a/client/src/services/AuthService.ts b/client/src/services/AuthService.ts index 682a7b41..8fc3c635 100644 --- a/client/src/services/AuthService.ts +++ b/client/src/services/AuthService.ts @@ -1,13 +1,14 @@ import HttpServiceV1, { type HttpOptions } from './HttpServiceV1'; -import type { Auth0VueClient } from '@auth0/auth0-vue'; +import type { Auth0VueClient, User } from '@auth0/auth0-vue'; import type { UserInfo } from '@/models'; +import type { Ref } from 'vue'; export default class AuthService { - static async getAccessTokenAsync(auth0: Auth0VueClient, options: HttpOptions={}): Promise { + static async getAccessTokenAsync(auth0: Auth0VueClient, options: HttpOptions = {}): Promise { return auth0.getAccessTokenSilently(); } - static async getUserInfoAsync(auth0: Auth0VueClient, options: HttpOptions={}): Promise { + static async getUserInfoAsync(auth0: Auth0VueClient, options: HttpOptions = {}): Promise { try { return await HttpServiceV1.getAsync( 'user', @@ -23,10 +24,14 @@ export default class AuthService { } static isAdmin(auth0: Auth0VueClient): boolean { - return auth0.isAuthenticated && [ + if (auth0.user.value === null || !auth0.isAuthenticated) { + return false; + } + const user: Ref = auth0.user as Ref; + return [ "exokomodo@gmail.com", "brandonapol@cedarville.edu", - ].includes(auth0.user.value.email ?? ''); + ].includes(user.value.email ?? ''); } static login(auth0: Auth0VueClient): void {