From 1293d39bd38d7d73352a6175f0550128a0ecf768 Mon Sep 17 00:00:00 2001 From: James Orson Date: Fri, 12 Apr 2024 16:20:38 -0700 Subject: [PATCH] Fix AuthService types --- client/src/services/AuthService.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 {