This commit is contained in:
Manav Rathi 2024-06-07 10:06:41 +05:30
parent cafead44d4
commit 7356522c6f
No known key found for this signature in database
2 changed files with 21 additions and 4 deletions

View File

@ -31,6 +31,7 @@ import { PAGES } from "../constants/pages";
import { configureSRP } from "../services/srp";
import type { PageProps } from "../types/page";
import type { SRPSetupAttributes } from "../types/srp";
import { redirectUserToPasskeyVerificationFlow } from "../services/passkey";
const Page: React.FC<PageProps> = ({ appContext }) => {
const { appName, logout } = appContext;
@ -85,9 +86,7 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
isTwoFactorPasskeysEnabled: true,
});
setIsFirstLogin(true);
window.location.href = `${accountsAppURL()}/passkeys/verify?passkeySessionID=${passkeySessionID}&redirect=${
window.location.origin
}/passkeys/finish`;
redirectUserToPasskeyVerificationFlow(passkeySessionID);
router.push(PAGES.CREDENTIALS);
} else if (twoFactorSessionID) {
setData(LS_KEYS.USER, {

View File

@ -1,9 +1,27 @@
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { accountsAppURL, getEndpoint } from "@ente/shared/network/api";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
/**
* Redirect user to accounts.ente.io (or its equivalent), to a page where they
* can authenticate using their second factor, a passkey they've configured.
*
* On successful verification, accounts.ente.io will redirect back to our
* `/passkeys/finish` page.
*
* @param passkeySessionID An identifier provided by museum for this passkey
* verification session.
*/
export const redirectUserToPasskeyVerificationFlow = (
passkeySessionID: string,
) => {
const redirect = `${window.location.origin}/passkeys/finish`;
const params = new URLSearchParams({ passkeySessionID, redirect });
window.location.href = `${accountsAppURL()}/passkeys/verify?${params.toString()}`;
};
export const isPasskeyRecoveryEnabled = async () => {
try {
const token = getToken();