aboutsummaryrefslogtreecommitdiff
path: root/src/server/authentication/models/user_utils.ts
blob: 1497a4ba4832e29f67b82d8caf0f9503ff7d0db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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?")
            }
        });
    }
}