From b204472c37fd9660ef730d4555f98efee280ec5e Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Wed, 14 Apr 2021 01:17:07 -0500 Subject: [PATCH] Add temporary home page with logout button. Enable DB synchronization --- src/app/auth.ts | 20 ++++++++++++++------ src/app/views/Home.vue | 13 +++++++++++-- src/server/services/Database.ts | 3 ++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/app/auth.ts b/src/app/auth.ts index b1fb896..34973c1 100644 --- a/src/app/auth.ts +++ b/src/app/auth.ts @@ -1,6 +1,11 @@ - import jwtDecode from "jwt-decode"; +interface IUser { + id: number, + name: string, + isAdmin: boolean +} + /** * The active JWT */ @@ -9,11 +14,7 @@ import jwtDecode from "jwt-decode"; /** * The decoded user object */ -let user: { - id: number, - name: string, - isAdmin: boolean -} | null; +let user: IUser | null; /** * Check if the user is an admin @@ -29,6 +30,13 @@ export function isAuthenticated() { return Boolean(token); } +/** + * Get the logged in user (assumes authentication has been checked) + */ +export function getUser() { + return user; +} + /** * Load the token from local storage */ diff --git a/src/app/views/Home.vue b/src/app/views/Home.vue index a33cb9d..4799125 100644 --- a/src/app/views/Home.vue +++ b/src/app/views/Home.vue @@ -1,11 +1,20 @@ diff --git a/src/server/services/Database.ts b/src/server/services/Database.ts index 4f20fc6..baf2d0d 100644 --- a/src/server/services/Database.ts +++ b/src/server/services/Database.ts @@ -33,7 +33,8 @@ export default class Database extends Service username : process.env["DB_USER"], password : password, database : process.env["DB_DATABASE"], - synchronize: process.env["NODE_ENV"] != "production", + // synchronize: process.env["NODE_ENV"] != "production", + synchronize: true, // Seems stable enough for my liking entities : Object.values(entities), migrations : ["src/migrations/*.ts"] });