diff options
author | tschicke-brown <tyler_schicke@brown.edu> | 2019-03-18 14:07:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-18 14:07:18 -0400 |
commit | 7d5bb60662dc6a879df261f9eafeda89d6574cd7 (patch) | |
tree | 8275d70be6aa728de3fea9af76b9422464143227 /src/server/authentication/models/current_user_utils.ts | |
parent | 861614569c2d72e0ee9a6a698f3978f609a3b2bc (diff) | |
parent | be117e38a63a558684baa69f719787f11dfc3be3 (diff) |
Merge pull request #65 from browngraphicslab/authentication
Authentication
Diffstat (limited to 'src/server/authentication/models/current_user_utils.ts')
-rw-r--r-- | src/server/authentication/models/current_user_utils.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts new file mode 100644 index 000000000..cc433eb73 --- /dev/null +++ b/src/server/authentication/models/current_user_utils.ts @@ -0,0 +1,29 @@ +import { DashUserModel } from "./user_model"; +import * as request from 'request' +import { RouteStore } from "../../RouteStore"; +import { ServerUtils } from "../../ServerUtil"; + +export class CurrentUserUtils { + private static curr_email: string; + private static curr_id: string; + + public static get email() { + return CurrentUserUtils.curr_email; + } + + public static get id() { + return CurrentUserUtils.curr_id; + } + + public static loadCurrentUser() { + request.get(ServerUtils.prepend(RouteStore.getCurrUser), (error, response, body) => { + if (body) { + let obj = JSON.parse(body); + CurrentUserUtils.curr_id = obj.id as string; + CurrentUserUtils.curr_email = obj.email as string; + } else { + throw new Error("There should be a user! Why does Dash think there isn't one?") + } + }); + } +}
\ No newline at end of file |