mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 03:23:40 +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 UserAvatar from "#/ui/UserAvatar";
|
||||
import { getMostRecentCookieWithLoginname } from "#/utils/cookies";
|
||||
import { RegisterTOTPResponse } from "@zitadel/server";
|
||||
import { ClientError } from "nice-grpc";
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
@@ -25,11 +27,20 @@ export default async function Page({
|
||||
const branding = await getBrandingSettings(server, organization);
|
||||
const { session, token } = await loadSession(loginName, organization);
|
||||
|
||||
let totpResponse;
|
||||
let totpResponse: RegisterTOTPResponse | undefined,
|
||||
totpError: ClientError | undefined;
|
||||
if (session && session.factors?.user?.id) {
|
||||
if (method === "time-based") {
|
||||
// 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") {
|
||||
// does not work
|
||||
await addOTPSMS(session.factors.user.id);
|
||||
@@ -67,6 +78,12 @@ export default async function Page({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{totpError && (
|
||||
<div className="py-4">
|
||||
<Alert>{totpError?.details}</Alert>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{session && (
|
||||
<UserAvatar
|
||||
loginName={loginName ?? session.factors?.user?.loginName}
|
||||
|
||||
Reference in New Issue
Block a user