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