resp on setup

This commit is contained in:
peintnermax
2024-04-29 15:26:08 +02:00
parent b75183868a
commit 83f9445762

View File

@@ -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}