mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 22:19:41 +01:00
feat: add support for adding fallback 2fa method
This commit is contained in:
@@ -47,11 +47,33 @@ class MFAManager {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async enable(type, code) {
|
async enable(type, code) {
|
||||||
|
return this._enable(type, code, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {"app" | "sms" | "email"} type
|
||||||
|
* @param {string} code
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async enableFallback(type, code) {
|
||||||
|
return this._enable(type, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {"app" | "sms" | "email"} type
|
||||||
|
* @param {string} code
|
||||||
|
* @param {boolean} isFallback
|
||||||
|
* @private
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async _enable(type, code, isFallback) {
|
||||||
const token = await this.tokenManager.getAccessToken();
|
const token = await this.tokenManager.getAccessToken();
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
return await http.post(
|
return await http.post(
|
||||||
`${constants.AUTH_HOST}${ENDPOINTS.enable}`,
|
`${constants.AUTH_HOST}${ENDPOINTS.enable}`,
|
||||||
{ type, code },
|
{ type, code, isFallback },
|
||||||
token
|
token
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user