mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-24 21:54:03 +00:00
Merge pull request #325 from zitadel/buf-gen-branch
send code on verify page visit, generate from branch
This commit is contained in:
@@ -3,7 +3,7 @@ import { DynamicTheme } from "@/components/dynamic-theme";
|
||||
import { UserAvatar } from "@/components/user-avatar";
|
||||
import { VerifyForm } from "@/components/verify-form";
|
||||
import { VerifyRedirectButton } from "@/components/verify-redirect-button";
|
||||
import { resendVerification } from "@/lib/server/verify";
|
||||
import { sendCode } from "@/lib/server/verify";
|
||||
import { loadMostRecentSession } from "@/lib/session";
|
||||
import {
|
||||
getBrandingSettings,
|
||||
@@ -44,7 +44,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
||||
});
|
||||
|
||||
if (!skipsend && sessionFactors?.factors?.user?.id) {
|
||||
await resendVerification({
|
||||
await sendCode({
|
||||
userId: sessionFactors?.factors?.user?.id,
|
||||
isInvite: invite === "true",
|
||||
}).catch((error) => {
|
||||
@@ -54,7 +54,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
||||
}
|
||||
} else if ("userId" in searchParams && userId) {
|
||||
if (!skipsend) {
|
||||
await resendVerification({
|
||||
await sendCode({
|
||||
userId,
|
||||
isInvite: invite === "true",
|
||||
}).catch((error) => {
|
||||
|
@@ -7,6 +7,7 @@ import {
|
||||
listAuthenticationMethodTypes,
|
||||
resendEmailCode,
|
||||
resendInviteCode,
|
||||
sendEmailCode,
|
||||
verifyEmail,
|
||||
verifyInviteCode,
|
||||
} from "@/lib/zitadel";
|
||||
@@ -191,6 +192,11 @@ export async function resendVerification(command: resendVerifyEmailCommand) {
|
||||
: resendEmailCode(command.userId, host, command.authRequestId);
|
||||
}
|
||||
|
||||
export async function sendCode(command: resendVerifyEmailCommand) {
|
||||
const host = (await headers()).get("host");
|
||||
return sendEmailCode(command.userId, host, command.authRequestId);
|
||||
}
|
||||
|
||||
export type SendVerificationRedirectWithoutCheckCommand = {
|
||||
organization?: string;
|
||||
authRequestId?: string;
|
||||
|
@@ -15,6 +15,7 @@ import {
|
||||
ResendEmailCodeRequest,
|
||||
ResendEmailCodeRequestSchema,
|
||||
RetrieveIdentityProviderIntentRequest,
|
||||
SendEmailCodeRequestSchema,
|
||||
SetPasswordRequest,
|
||||
SetPasswordRequestSchema,
|
||||
VerifyPasskeyRegistrationRequest,
|
||||
@@ -273,6 +274,32 @@ export async function resendInviteCode(userId: string) {
|
||||
return userService.resendInviteCode({ userId }, {});
|
||||
}
|
||||
|
||||
export async function sendEmailCode(
|
||||
userId: string,
|
||||
host: string | null,
|
||||
authRequestId?: string,
|
||||
) {
|
||||
let medium = create(SendEmailCodeRequestSchema, {
|
||||
userId,
|
||||
});
|
||||
|
||||
if (host) {
|
||||
medium = create(SendEmailCodeRequestSchema, {
|
||||
...medium,
|
||||
verification: {
|
||||
case: "sendCode",
|
||||
value: create(SendEmailVerificationCodeSchema, {
|
||||
urlTemplate:
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true` +
|
||||
(authRequestId ? `&authRequestId=${authRequestId}` : ""),
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return userService.sendEmailCode(medium, {});
|
||||
}
|
||||
|
||||
export async function createInviteCode(userId: string, host: string | null) {
|
||||
let medium = create(SendInviteCodeSchema, {
|
||||
applicationName: "Typescript Login",
|
||||
|
@@ -11,7 +11,7 @@
|
||||
],
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"generate": "buf generate https://github.com/zitadel/zitadel.git --path ./proto/zitadel",
|
||||
"generate": "buf generate https://github.com/zitadel/zitadel.git#branch=send-email-code --path ./proto/zitadel",
|
||||
"clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate"
|
||||
},
|
||||
"dependencies": {
|
||||
|
Reference in New Issue
Block a user