rm custom config, fix password reset

This commit is contained in:
peintnermax
2024-09-10 13:54:09 +02:00
parent 386ed7d297
commit 1466bb3b70
5 changed files with 18 additions and 17 deletions

View File

@@ -1 +1 @@
custom-config.ts custom-config.js

View File

@@ -1,12 +0,0 @@
const customConfig = {
session: {
lifetime_in_seconds: 7200,
},
selfservice: {
change_password: {
enabled: false,
},
},
};
module.exports = customConfig;

View File

@@ -15,7 +15,7 @@ const defaultConfig: Config = {
}, },
selfservice: { selfservice: {
change_password: { change_password: {
enabled: true, enabled: false,
}, },
}, },
}; };

View File

@@ -15,8 +15,8 @@ export async function resetPassword(command: ResetPasswordCommand) {
if ( if (
!users.details || !users.details ||
Number(users.details.totalResult) !== 1 || users.details.totalResult !== BigInt(1) ||
users.result[0].userId !users.result[0].userId
) { ) {
throw Error("Could not find user"); throw Error("Could not find user");
} }

View File

@@ -9,7 +9,7 @@ import { AuthenticationMethodType } from "@zitadel/proto/zitadel/user/v2/user_se
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import Alert from "./Alert"; import Alert, { AlertType } from "./Alert";
import BackButton from "./BackButton"; import BackButton from "./BackButton";
import { Button, ButtonVariants } from "./Button"; import { Button, ButtonVariants } from "./Button";
import { TextInput } from "./Input"; import { TextInput } from "./Input";
@@ -40,6 +40,7 @@ export default function PasswordForm({
mode: "onBlur", mode: "onBlur",
}); });
const [info, setInfo] = useState<string>("");
const [error, setError] = useState<string>(""); const [error, setError] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
@@ -69,6 +70,7 @@ export default function PasswordForm({
async function resetPasswordAndContinue() { async function resetPasswordAndContinue() {
setError(""); setError("");
setInfo("");
setLoading(true); setLoading(true);
const response = await resetPassword({ const response = await resetPassword({
@@ -81,6 +83,10 @@ export default function PasswordForm({
setLoading(false); setLoading(false);
if (response) {
setInfo("Password was reset. Please check your email.");
}
return response; return response;
} }
@@ -88,6 +94,7 @@ export default function PasswordForm({
value: Inputs, value: Inputs,
): Promise<boolean | void> { ): Promise<boolean | void> {
const submitted = await submitPassword(value); const submitted = await submitPassword(value);
setInfo("");
// if user has mfa -> /otp/[method] or /u2f // if user has mfa -> /otp/[method] or /u2f
// if mfa is forced and user has no mfa -> /mfa/set // if mfa is forced and user has no mfa -> /mfa/set
// if no passwordless -> /passkey/add // if no passwordless -> /passkey/add
@@ -242,6 +249,12 @@ export default function PasswordForm({
)} )}
</div> </div>
{info && (
<div className="py-4">
<Alert type={AlertType.INFO}>{info}</Alert>
</div>
)}
{error && ( {error && (
<div className="py-4"> <div className="py-4">
<Alert>{error}</Alert> <Alert>{error}</Alert>