From c8998c292d48e833f66cb43ea2c945f1a865a10e Mon Sep 17 00:00:00 2001 From: jw255 Date: Sun, 15 Apr 2018 18:03:01 +0100 Subject: fixed fetching current_user --- src/app.ts | 2 +- src/db/model/User.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/app.ts b/src/app.ts index e9d1d68..4dfeeda 100644 --- a/src/app.ts +++ b/src/app.ts @@ -77,7 +77,7 @@ class App { .unless({path: [ '/', '/cs3099group-be-4/oauth/token', - '/cs3099group-be-4/_supported_protocols_' + '/cs3099group-be-4/_supported_protocols_' ] }) ); this.express.use(passport.initialize()); diff --git a/src/db/model/User.ts b/src/db/model/User.ts index 171e899..3a0ef26 100644 --- a/src/db/model/User.ts +++ b/src/db/model/User.ts @@ -126,18 +126,20 @@ export default class User extends Model { } public get fullInfo(): UserFullInfo { + console.log("fullinfo called") // FIXME: Fetch these things if they aren't already present if (this.userGroups === undefined) { - throw new Error('userGroups undefined'); + this.userGroups = []; } else if (this.projects === undefined) { - throw new Error('projects undefined'); + this.projects = []; } + console.log("2") return { username : this.username, - privileges: this.userGroups + privileges: this.userGroups! .filter((ug: UserGroup): boolean => ug.name !== null) .map((ug: UserGroup): string => ug.name as string), - projects : this.projects.map( + projects : this.projects!.map( (p: Project): ProjectInfo => this.getProjectInfo(p) ), // TODO: Check if we have anything to use these for yet? -- cgit v1.2.1