mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 08:23:16 +00:00
resp on setup
This commit is contained in:
@@ -11,6 +11,8 @@ import DynamicTheme from "#/ui/DynamicTheme";
|
|||||||
import TOTPRegister from "#/ui/TOTPRegister";
|
import TOTPRegister from "#/ui/TOTPRegister";
|
||||||
import UserAvatar from "#/ui/UserAvatar";
|
import UserAvatar from "#/ui/UserAvatar";
|
||||||
import { getMostRecentCookieWithLoginname } from "#/utils/cookies";
|
import { getMostRecentCookieWithLoginname } from "#/utils/cookies";
|
||||||
|
import { RegisterTOTPResponse } from "@zitadel/server";
|
||||||
|
import { ClientError } from "nice-grpc";
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
searchParams,
|
searchParams,
|
||||||
@@ -25,11 +27,20 @@ export default async function Page({
|
|||||||
const branding = await getBrandingSettings(server, organization);
|
const branding = await getBrandingSettings(server, organization);
|
||||||
const { session, token } = await loadSession(loginName, organization);
|
const { session, token } = await loadSession(loginName, organization);
|
||||||
|
|
||||||
let totpResponse;
|
let totpResponse: RegisterTOTPResponse | undefined,
|
||||||
|
totpError: ClientError | undefined;
|
||||||
if (session && session.factors?.user?.id) {
|
if (session && session.factors?.user?.id) {
|
||||||
if (method === "time-based") {
|
if (method === "time-based") {
|
||||||
// inconsistency with token: email works with machine token, totp works with session token
|
// inconsistency with token: email works with machine token, totp works with session token
|
||||||
totpResponse = await registerTOTP(session.factors.user.id, token);
|
await registerTOTP(session.factors.user.id, token)
|
||||||
|
.then((resp) => {
|
||||||
|
if (resp) {
|
||||||
|
totpResponse = resp;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
totpError = error;
|
||||||
|
});
|
||||||
} else if (method === "sms") {
|
} else if (method === "sms") {
|
||||||
// does not work
|
// does not work
|
||||||
await addOTPSMS(session.factors.user.id);
|
await addOTPSMS(session.factors.user.id);
|
||||||
@@ -67,6 +78,12 @@ export default async function Page({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{totpError && (
|
||||||
|
<div className="py-4">
|
||||||
|
<Alert>{totpError?.details}</Alert>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{session && (
|
{session && (
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
loginName={loginName ?? session.factors?.user?.loginName}
|
loginName={loginName ?? session.factors?.user?.loginName}
|
||||||
|
|||||||
Reference in New Issue
Block a user