reset-password

This commit is contained in:
Bright 2025-02-21 17:26:11 +07:00
parent 626be7dae6
commit 86be7e9778
2 changed files with 48 additions and 0 deletions

View file

@ -32,6 +32,7 @@ import {
enableStatus,
getUserByUsername,
changeUserPassword,
resetPassword
} from "../keycloak";
import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile";
@ -828,4 +829,19 @@ export class KeycloakController extends Controller {
}
return result;
}
@Post("user/reset-password")
async forgetPassword(
@Request() request: { user: { sub: string; preferred_username: string } },
@Body()
body: {
username: string;
},
) {
const result = await resetPassword(body.username);
if (!result) {
throw new Error("Failed. Cannot change password.");
}
return result;
}
}