mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 06:52:24 +00:00
chore: fix u2f verify api call
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
import { getSession, verifyU2FRegistration } from "@/lib/zitadel";
|
import { getSession, verifyU2FRegistration } from "@/lib/zitadel";
|
||||||
import { getSessionCookieById } from "@zitadel/next";
|
import { getSessionCookieById } from "@zitadel/next";
|
||||||
import { NextRequest, NextResponse, userAgent } from "next/server";
|
import { NextRequest, NextResponse, userAgent } from "next/server";
|
||||||
import { VerifyU2FRegistrationRequest } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
import {
|
||||||
import { PlainMessage } from "@zitadel/client";
|
VerifyU2FRegistrationRequestSchema,
|
||||||
|
VerifyU2FRegistrationResponseSchema,
|
||||||
|
} from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
||||||
|
import { createMessage, toJson } from "@zitadel/client";
|
||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
@@ -22,18 +25,26 @@ export async function POST(request: NextRequest) {
|
|||||||
const userId = session?.session?.factors?.user?.id;
|
const userId = session?.session?.factors?.user?.id;
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
let req: PlainMessage<VerifyU2FRegistrationRequest> = {
|
// TODO: this does not make sens to me
|
||||||
publicKeyCredential,
|
// We create the object, and later on we assign another object to it.
|
||||||
u2fId,
|
// let req: VerifyU2FRegistrationRequest = {
|
||||||
userId,
|
// publicKeyCredential,
|
||||||
tokenName: passkeyName,
|
// u2fId,
|
||||||
};
|
// userId,
|
||||||
|
// tokenName: passkeyName,
|
||||||
|
// };
|
||||||
|
|
||||||
req = VerifyU2FRegistrationRequest.fromJson(request as any);
|
const req = createMessage(
|
||||||
|
VerifyU2FRegistrationRequestSchema,
|
||||||
|
// TODO: why did we passed the request instead of body here?
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
|
||||||
return verifyU2FRegistration(req)
|
return verifyU2FRegistration(req)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
return NextResponse.json(resp);
|
return NextResponse.json(
|
||||||
|
toJson(VerifyU2FRegistrationResponseSchema, resp),
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
return NextResponse.json(error, { status: 500 });
|
return NextResponse.json(error, { status: 500 });
|
||||||
|
|||||||
Reference in New Issue
Block a user