Skip to content

Commit

Permalink
Fix AuthService types
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaorson committed Apr 12, 2024
1 parent a905488 commit 1293d39
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions client/src/services/AuthService.ts
Original file line number Diff line number Diff line change
@@ -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<string | null> {
static async getAccessTokenAsync(auth0: Auth0VueClient, options: HttpOptions = {}): Promise<string | null> {
return auth0.getAccessTokenSilently();
}

static async getUserInfoAsync(auth0: Auth0VueClient, options: HttpOptions={}): Promise<UserInfo> {
static async getUserInfoAsync(auth0: Auth0VueClient, options: HttpOptions = {}): Promise<UserInfo> {
try {
return await HttpServiceV1.getAsync<UserInfo>(
'user',
Expand All @@ -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<User> = auth0.user as Ref<User>;
return [
"exokomodo@gmail.com",
"brandonapol@cedarville.edu",
].includes(auth0.user.value.email ?? '');
].includes(user.value.email ?? '');
}

static login(auth0: Auth0VueClient): void {
Expand Down

0 comments on commit 1293d39

Please sign in to comment.