Skip to content

Commit

Permalink
refactor: user model
Browse files Browse the repository at this point in the history
  • Loading branch information
bartduisters committed May 20, 2022
1 parent 0b03ce0 commit ac8a284
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/components/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@ export interface Hero {
number: number;
name: string;
}

export interface User {
_id: string;
email: string,
permissions: Array<string>,
isVerified: boolean,
name: {
firstName: string,
lastName: string,
showName: boolean,
}
}
7 changes: 1 addition & 6 deletions src/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

import { api } from 'src/boot/axios';
import { User } from 'src/components/models';
import { readonly, ref, computed } from 'vue';

interface User {
_id: string;
}

const authenticatedUser = ref({} as User);

const useAuth = () => {
Expand All @@ -19,7 +16,6 @@ const useAuth = () => {
strategy: 'jwt',
accessToken
}).then((result: { data: { accessToken: string, user: User } }) => {
console.log(result);
authenticatedUser.value = result.data.user;
}).catch(() => {
localStorage.removeItem('accessToken');
Expand All @@ -40,7 +36,6 @@ const useAuth = () => {
if (accessToken) {
localStorage.setItem('accessToken', accessToken);
authenticatedUser.value = result.data.user;
console.log(result.data.user);
alert('Login successful');
};
})
Expand Down

0 comments on commit ac8a284

Please sign in to comment.