summaryrefslogtreecommitdiff
path: root/web/src/services/Configuration.ts
blob: e69d4773190cd02de012c36c611d5a69c2ebcc84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { Configuration } from "@models/Configuration";
import { ConfigurationPath } from "@services/Api";
import { Get } from "@services/Client";
import { Method2FA, toSecondFactorMethod } from "@services/UserInfo";

interface ConfigurationPayload {
    available_methods: Method2FA[];
    password_change_disabled: boolean;
    password_reset_disabled: boolean;
}

export async function getConfiguration(): Promise<Configuration> {
    const config = await Get<ConfigurationPayload>(ConfigurationPath);
    return {
        ...config,
        available_methods: new Set(config.available_methods.map(toSecondFactorMethod)),
        password_change_disabled: config.password_change_disabled,
        password_reset_disabled: config.password_reset_disabled,
    };
}