accounts-frontend/packages/app/services/api/mfa.ts
2020-05-24 02:08:24 +03:00

28 lines
670 B
TypeScript

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