fix verify response

This commit is contained in:
peintnermax
2024-10-21 16:47:12 +02:00
parent 98a5e042b2
commit 8edd22a6a4
4 changed files with 29 additions and 15 deletions

View File

@@ -238,18 +238,12 @@ export const PASSWORD = (alreadyAdded: boolean, link: string) => {
)}
>
<svg
className="w-8 h-7 mr-4 fill-current"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
className="w-8 h-8 mr-4"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M7.864 4.243A7.5 7.5 0 0119.5 10.5c0 2.92-.556 5.709-1.568 8.268M5.742 6.364A7.465 7.465 0 004.5 10.5a7.464 7.464 0 01-1.15 3.993m1.989 3.559A11.209 11.209 0 008.25 10.5a3.75 3.75 0 117.5 0c0 .527-.021 1.049-.064 1.565M12 10.5a14.94 14.94 0 01-3.6 9.75m6.633-4.596a18.666 18.666 0 01-2.485 5.33"
/>
<title>form-textbox-password</title>
<path d="M17,7H22V17H17V19A1,1 0 0,0 18,20H20V22H17.5C16.95,22 16,21.55 16,21C16,21.55 15.05,22 14.5,22H12V20H14A1,1 0 0,0 15,19V5A1,1 0 0,0 14,4H12V2H14.5C15.05,2 16,2.45 16,3C16,2.45 16.95,2 17.5,2H20V4H18A1,1 0 0,0 17,5V7M2,7H13V9H4V15H13V17H2V7M20,15V9H17V15H20M8.5,12A1.5,1.5 0 0,0 7,10.5A1.5,1.5 0 0,0 5.5,12A1.5,1.5 0 0,0 7,13.5A1.5,1.5 0 0,0 8.5,12M13,10.89C12.39,10.33 11.44,10.38 10.88,11C10.32,11.6 10.37,12.55 11,13.11C11.55,13.63 12.43,13.63 13,13.11V10.89Z" />
</svg>
<span>Password</span>
</div>

View File

@@ -1,7 +1,7 @@
"use client";
import { Alert } from "@/components/alert";
import { resendVerifyEmail, verifyUser } from "@/lib/server/email";
import { resendVerification, verifyUser } from "@/lib/server/email";
import { LoginSettings } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
import { AuthenticationMethodType } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
import { useTranslations } from "next-intl";
@@ -49,7 +49,7 @@ export function VerifyEmailForm({
const [authMethods, setAuthMethods] = useState<
AuthenticationMethodType[] | null
>(null);
>([]);
useEffect(() => {
if (code && userId) {
@@ -82,10 +82,14 @@ export function VerifyEmailForm({
async function resendCode() {
setLoading(true);
const response = await resendVerifyEmail({
const response = await resendVerification({
userId,
isInvite: isInvite,
}).catch(() => {
setError("Could not resend email");
setLoading(false);
return;
});
setLoading(false);
@@ -94,12 +98,15 @@ export function VerifyEmailForm({
async function submitCodeAndContinue(value: Inputs): Promise<boolean | void> {
setLoading(true);
console.log("verifyUser", value.code, userId, isInvite);
const verifyResponse = await verifyUser({
code: value.code,
userId,
isInvite: isInvite,
}).catch(() => {
setError("Could not verify email");
return;
});
setLoading(false);
@@ -111,8 +118,10 @@ export function VerifyEmailForm({
if (verifyResponse.authMethodTypes) {
setAuthMethods(verifyResponse.authMethodTypes);
return;
}
// if auth methods fall trough, we complete to login
const params = new URLSearchParams({});
if (organization) {

View File

@@ -3,6 +3,7 @@
import {
listAuthenticationMethodTypes,
resendEmailCode,
resendInviteCode,
verifyEmail,
verifyInviteCode,
} from "@/lib/zitadel";
@@ -35,8 +36,11 @@ export async function verifyUser(command: VerifyUserByEmailCommand) {
type resendVerifyEmailCommand = {
userId: string;
isInvite: boolean;
};
export async function resendVerifyEmail(command: resendVerifyEmailCommand) {
return resendEmailCode(command.userId);
export async function resendVerification(command: resendVerifyEmailCommand) {
return command.isInvite
? resendEmailCode(command.userId)
: resendInviteCode(command.userId);
}

View File

@@ -281,7 +281,13 @@ export async function addHumanUser({
organization,
}: AddHumanUserData) {
return userService.addHumanUser({
email: { email },
email: {
email,
verification: {
case: "isVerified",
value: false,
},
},
username: email,
profile: { givenName: firstName, familyName: lastName },
organization: organization
@@ -309,6 +315,7 @@ export async function verifyInviteCode(
}
export async function resendInviteCode(userId: string) {
console.log("resetInit");
return userService.resendInviteCode({ userId }, {});
}