accounts-frontend/packages/app/services/api/mfa.ts

28 lines
670 B
TypeScript
Raw Normal View History

import request, { Resp } from 'app/services/request';
export function getSecret(
2020-05-24 04:38:24 +05:30
id: number,
): Promise<
2020-05-24 04:38:24 +05:30
Resp<{
qr: string;
secret: string;
uri: string;
}>
> {
2020-05-24 04:38:24 +05:30
return request.get(`/api/v1/accounts/${id}/two-factor-auth`);
}
2020-05-24 04:38:24 +05:30
export function enable(id: number, totp: string, password?: string): Promise<Resp<any>> {
return request.post(`/api/v1/accounts/${id}/two-factor-auth`, {
totp,
password,
});
}
2020-05-24 04:38:24 +05:30
export function disable(id: number, totp: string, password?: string): Promise<Resp<any>> {
return request.delete(`/api/v1/accounts/${id}/two-factor-auth`, {
totp,
password,
});
}