mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 11:20:00 +00:00
cleanup verification logic
This commit is contained in:
@@ -2,17 +2,11 @@ import { Alert, AlertType } from "@/components/alert";
|
|||||||
import { DynamicTheme } from "@/components/dynamic-theme";
|
import { DynamicTheme } from "@/components/dynamic-theme";
|
||||||
import { UserAvatar } from "@/components/user-avatar";
|
import { UserAvatar } from "@/components/user-avatar";
|
||||||
import { VerifyForm } from "@/components/verify-form";
|
import { VerifyForm } from "@/components/verify-form";
|
||||||
import { VerifyRedirectButton } from "@/components/verify-redirect-button";
|
|
||||||
import { sendEmailCode } from "@/lib/server/verify";
|
import { sendEmailCode } from "@/lib/server/verify";
|
||||||
import { getServiceUrlFromHeaders } from "@/lib/service-url";
|
import { getServiceUrlFromHeaders } from "@/lib/service-url";
|
||||||
import { loadMostRecentSession } from "@/lib/session";
|
import { loadMostRecentSession } from "@/lib/session";
|
||||||
import {
|
import { getBrandingSettings, getUserByID } from "@/lib/zitadel";
|
||||||
getBrandingSettings,
|
|
||||||
getUserByID,
|
|
||||||
listAuthenticationMethodTypes,
|
|
||||||
} from "@/lib/zitadel";
|
|
||||||
import { HumanUser, User } from "@zitadel/proto/zitadel/user/v2/user_pb";
|
import { HumanUser, User } from "@zitadel/proto/zitadel/user/v2/user_pb";
|
||||||
import { AuthenticationMethodType } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
@@ -100,17 +94,6 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
|||||||
throw Error("Failed to get user id");
|
throw Error("Failed to get user id");
|
||||||
}
|
}
|
||||||
|
|
||||||
let authMethods: AuthenticationMethodType[] | null = null;
|
|
||||||
if (human?.email?.isVerified) {
|
|
||||||
const authMethodsResponse = await listAuthenticationMethodTypes({
|
|
||||||
serviceUrl,
|
|
||||||
userId,
|
|
||||||
});
|
|
||||||
if (authMethodsResponse.authMethodTypes) {
|
|
||||||
authMethods = authMethodsResponse.authMethodTypes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
initial: "true", // defines that a code is not required and is therefore not shown in the UI
|
initial: "true", // defines that a code is not required and is therefore not shown in the UI
|
||||||
@@ -168,18 +151,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* show a button to setup auth method for the user otherwise show the UI for reverifying */}
|
{/* always show the code form / TODO improve UI for email links which were already used (currently we get an error code 3 due being reused) */}
|
||||||
{human?.email?.isVerified ? (
|
|
||||||
// show page for already verified users
|
|
||||||
<VerifyRedirectButton
|
|
||||||
userId={id}
|
|
||||||
loginName={loginName}
|
|
||||||
organization={organization}
|
|
||||||
requestId={requestId}
|
|
||||||
authMethods={authMethods}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
// check if auth methods are set
|
|
||||||
<VerifyForm
|
<VerifyForm
|
||||||
loginName={loginName}
|
loginName={loginName}
|
||||||
organization={organization}
|
organization={organization}
|
||||||
@@ -188,7 +160,6 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
|||||||
isInvite={invite === "true"}
|
isInvite={invite === "true"}
|
||||||
requestId={requestId}
|
requestId={requestId}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</DynamicTheme>
|
</DynamicTheme>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user