mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 06:42:59 +00:00
login after register with passkey
This commit is contained in:
@@ -10,7 +10,8 @@ export default async function Page({
|
||||
}: {
|
||||
searchParams: Record<string | number | symbol, string | undefined>;
|
||||
}) {
|
||||
const { loginName, promptPasswordless, organization } = searchParams;
|
||||
const { loginName, promptPasswordless, organization, authRequestId } =
|
||||
searchParams;
|
||||
|
||||
const sessionFactors = await loadSession(loginName);
|
||||
|
||||
@@ -75,6 +76,8 @@ export default async function Page({
|
||||
<RegisterPasskey
|
||||
sessionId={sessionFactors.id}
|
||||
isPrompt={!!promptPasswordless}
|
||||
organization={organization}
|
||||
authRequestId={authRequestId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -452,7 +452,6 @@ export async function verifyPasskeyRegistration(
|
||||
{
|
||||
passkeyId,
|
||||
passkeyName,
|
||||
|
||||
publicKeyCredential,
|
||||
userId,
|
||||
},
|
||||
|
||||
@@ -6,16 +6,23 @@ import { useForm } from "react-hook-form";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Spinner } from "./Spinner";
|
||||
import Alert from "./Alert";
|
||||
import { RegisterPasskeyResponse } from "@zitadel/server";
|
||||
import { AuthRequest, RegisterPasskeyResponse } from "@zitadel/server";
|
||||
import { coerceToArrayBuffer, coerceToBase64Url } from "#/utils/base64";
|
||||
type Inputs = {};
|
||||
|
||||
type Props = {
|
||||
sessionId: string;
|
||||
isPrompt: boolean;
|
||||
authRequestId?: string;
|
||||
organization?: string;
|
||||
};
|
||||
|
||||
export default function RegisterPasskey({ sessionId, isPrompt }: Props) {
|
||||
export default function RegisterPasskey({
|
||||
sessionId,
|
||||
isPrompt,
|
||||
organization,
|
||||
authRequestId,
|
||||
}: Props) {
|
||||
const { register, handleSubmit, formState } = useForm<Inputs>({
|
||||
mode: "onBlur",
|
||||
});
|
||||
@@ -141,7 +148,20 @@ export default function RegisterPasskey({ sessionId, isPrompt }: Props) {
|
||||
},
|
||||
};
|
||||
return submitVerify(passkeyId, "", data, sessionId).then(() => {
|
||||
router.push("/accounts");
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (organization) {
|
||||
params.set("organization", organization);
|
||||
}
|
||||
|
||||
if (authRequestId) {
|
||||
params.set("authRequest", authRequestId);
|
||||
params.set("sessionId", sessionId);
|
||||
|
||||
router.push("/login?" + params);
|
||||
} else {
|
||||
router.push("/accounts?" + params);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setLoading(false);
|
||||
@@ -175,7 +195,18 @@ export default function RegisterPasskey({ sessionId, isPrompt }: Props) {
|
||||
<Button
|
||||
type="button"
|
||||
variant={ButtonVariants.Secondary}
|
||||
onClick={() => router.push("/accounts")}
|
||||
onClick={() => {
|
||||
const params = new URLSearchParams();
|
||||
if (authRequestId) {
|
||||
params.set("authRequestId", authRequestId);
|
||||
}
|
||||
|
||||
if (organization) {
|
||||
params.set("organization", organization);
|
||||
}
|
||||
|
||||
router.push("/accounts?" + params);
|
||||
}}
|
||||
>
|
||||
skip
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user