fix register session

This commit is contained in:
Max Peintner
2024-10-24 14:22:03 +02:00
parent fb656bc5e9
commit 93413bd3f4
3 changed files with 17 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ describe("register", () => {
});
});
it("should redirect a user who selects passwordless on register to /passkeys/add", () => {
it("should redirect a user who selects passwordless on register to /passkey/set", () => {
cy.visit("/register");
cy.get('input[autocomplete="firstname"]').focus().type("John");
cy.get('input[autocomplete="lastname"]').focus().type("Doe");

View File

@@ -69,6 +69,7 @@ export function RegisterFormWithoutPassword({
}).catch((error) => {
setError("Could not register user");
setLoading(false);
return;
});
if (response && "error" in response) {

View File

@@ -4,7 +4,10 @@ import { createSessionAndUpdateCookie } from "@/lib/server/cookie";
import { addHumanUser } from "@/lib/zitadel";
import { create } from "@zitadel/client";
import { Factors } from "@zitadel/proto/zitadel/session/v2/session_pb";
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
import {
ChecksJson,
ChecksSchema,
} from "@zitadel/proto/zitadel/session/v2/session_service_pb";
type RegisterUserCommand = {
email: string;
@@ -34,10 +37,18 @@ export async function registerUser(command: RegisterUserCommand) {
return { error: "Could not create user" };
}
const checks = create(ChecksSchema, {
let checkPayload: any = {
user: { search: { case: "userId", value: human.userId } },
password: { password: command.password },
});
};
if (command.password) {
checkPayload = {
...checkPayload,
password: { password: command.password },
} as ChecksJson;
}
const checks = create(ChecksSchema, checkPayload);
return createSessionAndUpdateCookie(
checks,