mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-16 05:32:07 +00:00
handle password redirect from browser
This commit is contained in:
@@ -12,6 +12,7 @@ import { create } from "@zitadel/client";
|
||||
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { redirect } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { FieldValues, useForm } from "react-hook-form";
|
||||
import { Alert } from "./alert";
|
||||
@@ -103,6 +104,11 @@ export function ChangePasswordForm({
|
||||
passwordResponse.error
|
||||
) {
|
||||
setError(passwordResponse.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (passwordResponse && passwordResponse.nextStep) {
|
||||
return redirect(passwordResponse.nextStep);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { create } from "@zitadel/client";
|
||||
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { LoginSettings } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { redirect, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Alert, AlertType } from "./alert";
|
||||
@@ -71,9 +71,14 @@ export function PasswordForm({
|
||||
|
||||
if (response && "error" in response && response.error) {
|
||||
setError(response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
return response;
|
||||
if (response && response.nextStep) {
|
||||
return redirect(response.nextStep);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
async function resetPasswordAndContinue() {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { create } from "@zitadel/client";
|
||||
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { redirect } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { FieldValues, useForm } from "react-hook-form";
|
||||
import { Alert } from "./alert";
|
||||
@@ -123,7 +124,14 @@ export function SetPasswordForm({
|
||||
passwordResponse.error
|
||||
) {
|
||||
setError(passwordResponse.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (passwordResponse && passwordResponse.nextStep) {
|
||||
return redirect(passwordResponse.nextStep);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { errors } = formState;
|
||||
|
||||
@@ -249,7 +249,8 @@ export async function sendPassword(command: UpdateSessionCommand) {
|
||||
params.append("organization", command.organization);
|
||||
}
|
||||
|
||||
return redirect(`/login?` + params);
|
||||
// move this to browser
|
||||
return { nextStep: `/login?${params}` };
|
||||
}
|
||||
|
||||
// without OIDC flow
|
||||
|
||||
Reference in New Issue
Block a user