mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-25 00:32:15 +00:00
# Which Problems Are Solved This pr updates major and minor dependencies and is the first step on getting our dependabot alerts cut down. # How the Problems Are Solved Depedency updates across the board eg: - Upgrade Angular to v21 - Upgrade next.js to v16.2 - Upgrade tailwind to v4 in the login - Upgrade vitest to v4 in the login This is an uncompleted list refer to the changed files for a full overview of all the updates. # Additional Changes Migrated all control flow in the console to the modern control flow syntax. Fixed the dependsOn setting for the @zitadel/login:test-unit nx target. # Additional Context - Closes https://github.com/zitadel/zitadel/issues/11274 --------- Co-authored-by: Max Peintner <[email protected]>
112 lines
3.4 KiB
TypeScript
112 lines
3.4 KiB
TypeScript
"use client";
|
|
|
|
import { handleServerActionResponse } from "@/lib/client-utils";
|
|
import { skipMFAAndContinueWithNextUrl } from "@/lib/server/session";
|
|
import { LoginSettings, SecondFactorType } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
|
|
import { AuthenticationMethodType } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
import { Alert } from "./alert";
|
|
import { EMAIL, SMS, TOTP, U2F } from "./auth-methods";
|
|
import { AutoSubmitForm } from "./auto-submit-form";
|
|
import { Translated } from "./translated";
|
|
|
|
type Props = {
|
|
userId: string;
|
|
loginName?: string;
|
|
sessionId?: string;
|
|
requestId?: string;
|
|
organization?: string;
|
|
loginSettings: LoginSettings;
|
|
userMethods: AuthenticationMethodType[];
|
|
checkAfter: boolean;
|
|
phoneVerified: boolean;
|
|
emailVerified: boolean;
|
|
force: boolean;
|
|
};
|
|
|
|
export function ChooseSecondFactorToSetup({
|
|
userId,
|
|
loginName,
|
|
sessionId,
|
|
requestId,
|
|
organization,
|
|
loginSettings,
|
|
userMethods,
|
|
checkAfter,
|
|
phoneVerified,
|
|
emailVerified,
|
|
force,
|
|
}: Props) {
|
|
const router = useRouter();
|
|
const params = new URLSearchParams({});
|
|
|
|
const [error, setError] = useState<string>("");
|
|
const [samlData, setSamlData] = useState<{ url: string; fields: Record<string, string> } | null>(null);
|
|
|
|
if (loginName) {
|
|
params.append("loginName", loginName);
|
|
}
|
|
if (sessionId) {
|
|
params.append("sessionId", sessionId);
|
|
}
|
|
if (requestId) {
|
|
params.append("requestId", requestId);
|
|
}
|
|
if (organization) {
|
|
params.append("organization", organization);
|
|
}
|
|
if (checkAfter) {
|
|
params.append("checkAfter", "true");
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{samlData && <AutoSubmitForm url={samlData.url} fields={samlData.fields} />}
|
|
<div className="grid w-full grid-cols-1 gap-5 pt-4">
|
|
{loginSettings.secondFactors.map((factor) => {
|
|
switch (factor) {
|
|
case SecondFactorType.OTP:
|
|
return TOTP(userMethods.includes(AuthenticationMethodType.TOTP), "/otp/time-based/set?" + params);
|
|
case SecondFactorType.U2F:
|
|
return U2F(userMethods.includes(AuthenticationMethodType.U2F), "/u2f/set?" + params);
|
|
case SecondFactorType.OTP_EMAIL:
|
|
return (
|
|
emailVerified && EMAIL(userMethods.includes(AuthenticationMethodType.OTP_EMAIL), "/otp/email/set?" + params)
|
|
);
|
|
case SecondFactorType.OTP_SMS:
|
|
return phoneVerified && SMS(userMethods.includes(AuthenticationMethodType.OTP_SMS), "/otp/sms/set?" + params);
|
|
default:
|
|
return null;
|
|
}
|
|
})}
|
|
</div>
|
|
{!force && (
|
|
<button
|
|
className="hover:text-primary-light-500 dark:hover:text-primary-dark-500 text-sm transition-all"
|
|
onClick={async () => {
|
|
const skipResponse = await skipMFAAndContinueWithNextUrl({
|
|
userId,
|
|
loginName,
|
|
sessionId,
|
|
organization,
|
|
requestId,
|
|
});
|
|
|
|
handleServerActionResponse(skipResponse, router, setSamlData, setError);
|
|
}}
|
|
type="button"
|
|
data-testid="reset-button"
|
|
>
|
|
<Translated i18nKey="set.skip" namespace="mfa" />
|
|
</button>
|
|
)}
|
|
{error && (
|
|
<div className="py-4" data-testid="error">
|
|
<Alert>{error}</Alert>
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
}
|