This commit is contained in:
daniel31x13 2023-11-19 08:56:03 -05:00
parent 9938d21499
commit 9a28552af5
2 changed files with 26 additions and 22 deletions

View File

@ -21,17 +21,19 @@ export default async function deleteUserById(
}; };
} }
// Then, we check if the provided password matches the one stored in the database // Then, we check if the provided password matches the one stored in the database (disabled in Keycloak integration)
const isPasswordValid = bcrypt.compareSync( if (!process.env.KEYCLOAK_CLIENT_SECRET) {
body.password, const isPasswordValid = bcrypt.compareSync(
user.password || "" body.password,
); user.password as string
);
if (!isPasswordValid) { if (!isPasswordValid) {
return { return {
response: "Invalid credentials.", response: "Invalid credentials.",
status: 401, // Unauthorized status: 401, // Unauthorized
}; };
}
} }
// Delete the user and all related data within a transaction // Delete the user and all related data within a transaction

View File

@ -25,7 +25,7 @@ export default function Password() {
}, },
}; };
if (password == "") { if (process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED !== "true" && password == "") {
return toast.error("Please fill the required fields."); return toast.error("Please fill the required fields.");
} }
@ -78,18 +78,20 @@ export default function Password() {
. This action is irreversible! . This action is irreversible!
</p> </p>
<div> {process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED !== "true" ? (
<p className="mb-2 text-black dark:text-white"> <div>
Confirm Your Password <p className="mb-2 text-black dark:text-white">
</p> Confirm Your Password
</p>
<TextInput <TextInput
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
placeholder="••••••••••••••" placeholder="••••••••••••••"
type="password" type="password"
/> />
</div> </div>
) : undefined}
{process.env.NEXT_PUBLIC_STRIPE ? ( {process.env.NEXT_PUBLIC_STRIPE ? (
<fieldset className="border rounded-md p-2 border-sky-500"> <fieldset className="border rounded-md p-2 border-sky-500">