aboutsummaryrefslogtreecommitdiffstats
path: root/src/wwwroot/scripts/api/account-api.ts
blob: 0d8604b9884d772609f12f05f0b76bdd00dbcc47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {LoginPayload} from "./account-api.types"

export function login(payload: LoginPayload, xsrf: string): Promise<Response> {
    return fetch("/api/account/login", {
        method: "post",
        body: JSON.stringify(payload),
        headers: {
            "Content-Type": "application/json;charset=utf-8",
            "XSRF-TOKEN": xsrf
        }
    });
}

export function logout(): Promise<Response> {
    return fetch("/api/account/logout");
}

export function updatePassword(newPassword: string): Promise<Response> {
    return fetch("/api/account/update-password", {
        method: "post",
        body: JSON.stringify({
            newPassword
        }),
        headers: {
            "Content-Type": "application/json;charset=utf-8"
        }
    });
}