2017-08-02 01:30:02 +05:30
|
|
|
// @flow
|
|
|
|
import type { Resp } from 'services/request';
|
2019-01-28 00:42:58 +05:30
|
|
|
import request from 'services/request';
|
2017-08-02 01:30:02 +05:30
|
|
|
|
2019-01-28 00:42:58 +05:30
|
|
|
export function getSecret(id: number): Promise<Resp<{
|
|
|
|
qr: string,
|
|
|
|
secret: string,
|
|
|
|
uri: string,
|
|
|
|
}>> {
|
|
|
|
return request.get(`/api/v1/accounts/${id}/two-factor-auth`);
|
|
|
|
}
|
2017-08-20 21:15:21 +05:30
|
|
|
|
2019-01-28 00:42:58 +05:30
|
|
|
export function enable(id: number, totp: string, password?: string): Promise<Resp<*>> {
|
|
|
|
return request.post(`/api/v1/accounts/${id}/two-factor-auth`, {
|
|
|
|
totp,
|
|
|
|
password,
|
|
|
|
});
|
|
|
|
}
|
2017-08-20 21:15:21 +05:30
|
|
|
|
2019-01-28 00:42:58 +05:30
|
|
|
export function disable(id: number, totp: string, password?: string): Promise<Resp<*>> {
|
|
|
|
return request.delete(`/api/v1/accounts/${id}/two-factor-auth`, {
|
|
|
|
totp,
|
|
|
|
password,
|
|
|
|
});
|
|
|
|
}
|