diff --git a/apps/login/.gitignore b/apps/login/.gitignore index 190545517ac..e2a663b5463 100644 --- a/apps/login/.gitignore +++ b/apps/login/.gitignore @@ -1 +1 @@ -custom-config.ts \ No newline at end of file +custom-config.js \ No newline at end of file diff --git a/apps/login/custom-config.js b/apps/login/custom-config.js deleted file mode 100644 index e08189f07f3..00000000000 --- a/apps/login/custom-config.js +++ /dev/null @@ -1,12 +0,0 @@ -const customConfig = { - session: { - lifetime_in_seconds: 7200, - }, - selfservice: { - change_password: { - enabled: false, - }, - }, -}; - -module.exports = customConfig; diff --git a/apps/login/default-config.ts b/apps/login/default-config.ts index 8088d8298cc..e5a1388fad8 100644 --- a/apps/login/default-config.ts +++ b/apps/login/default-config.ts @@ -15,7 +15,7 @@ const defaultConfig: Config = { }, selfservice: { change_password: { - enabled: true, + enabled: false, }, }, }; diff --git a/apps/login/src/lib/server/password.ts b/apps/login/src/lib/server/password.ts index 756f41f6713..020630cf1e8 100644 --- a/apps/login/src/lib/server/password.ts +++ b/apps/login/src/lib/server/password.ts @@ -15,8 +15,8 @@ export async function resetPassword(command: ResetPasswordCommand) { if ( !users.details || - Number(users.details.totalResult) !== 1 || - users.result[0].userId + users.details.totalResult !== BigInt(1) || + !users.result[0].userId ) { throw Error("Could not find user"); } diff --git a/apps/login/src/ui/PasswordForm.tsx b/apps/login/src/ui/PasswordForm.tsx index d9fbbdf0dba..4afa89c3208 100644 --- a/apps/login/src/ui/PasswordForm.tsx +++ b/apps/login/src/ui/PasswordForm.tsx @@ -9,7 +9,7 @@ import { AuthenticationMethodType } from "@zitadel/proto/zitadel/user/v2/user_se import { useRouter } from "next/navigation"; import { useState } from "react"; import { useForm } from "react-hook-form"; -import Alert from "./Alert"; +import Alert, { AlertType } from "./Alert"; import BackButton from "./BackButton"; import { Button, ButtonVariants } from "./Button"; import { TextInput } from "./Input"; @@ -40,6 +40,7 @@ export default function PasswordForm({ mode: "onBlur", }); + const [info, setInfo] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); @@ -69,6 +70,7 @@ export default function PasswordForm({ async function resetPasswordAndContinue() { setError(""); + setInfo(""); setLoading(true); const response = await resetPassword({ @@ -81,6 +83,10 @@ export default function PasswordForm({ setLoading(false); + if (response) { + setInfo("Password was reset. Please check your email."); + } + return response; } @@ -88,6 +94,7 @@ export default function PasswordForm({ value: Inputs, ): Promise { const submitted = await submitPassword(value); + setInfo(""); // if user has mfa -> /otp/[method] or /u2f // if mfa is forced and user has no mfa -> /mfa/set // if no passwordless -> /passkey/add @@ -242,6 +249,12 @@ export default function PasswordForm({ )} + {info && ( +
+ {info} +
+ )} + {error && (
{error}