feat: isPasskeyRecoveryEnabled in service
This commit is contained in:
parent
00f45ef39d
commit
1d4f92c39b
1 changed files with 24 additions and 0 deletions
24
web/packages/accounts/services/passkey.ts
Normal file
24
web/packages/accounts/services/passkey.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers"
|
||||
import { logError } from "@ente/shared/sentry";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
|
||||
export const isPasskeyRecoveryEnabled = async () => {
|
||||
try {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get("/users/two-factor/recovery-status", {}, {
|
||||
"X-Auth-Token": token,
|
||||
});
|
||||
|
||||
if (typeof resp.data === "undefined") {
|
||||
throw Error(CustomError.REQUEST_FAILED);
|
||||
}
|
||||
|
||||
return resp.isPasskeyRecoveryEnabled as boolean;
|
||||
|
||||
} catch (e) {
|
||||
logError(e, "failed to get passkey recovery status");
|
||||
throw e
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue