aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/authentication/models/current_user_utils.ts29
-rw-r--r--src/server/authentication/models/user_utils.ts22
-rw-r--r--src/server/index.ts7
3 files changed, 35 insertions, 23 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
diff --git a/src/server/authentication/models/user_utils.ts b/src/server/authentication/models/user_utils.ts
deleted file mode 100644
index 1497a4ba4..000000000
--- a/src/server/authentication/models/user_utils.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { DashUserModel } from "./user_model";
-import * as request from 'request'
-import { RouteStore } from "../../RouteStore";
-import { ServerUtils } from "../../ServerUtil";
-
-export class UserUtils {
- private static current: string;
-
- public static get currentUserId() {
- return UserUtils.current;
- }
-
- public static loadCurrentUserId() {
- request.get(ServerUtils.prepend(RouteStore.getCurrUser), (error, response, body) => {
- if (body) {
- UserUtils.current = JSON.parse(body) 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
diff --git a/src/server/index.ts b/src/server/index.ts
index 0512ebf72..6d8dd2d6c 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -151,7 +151,12 @@ addSecureRoute(
addSecureRoute(
Method.GET,
- (user, res) => res.send(JSON.stringify(user.id)),
+ (user, res) => {
+ res.send(JSON.stringify({
+ id: user.id,
+ email: user.email
+ }));
+ },
undefined,
RouteStore.getCurrUser
);