fix report & comment reset pass
This commit is contained in:
parent
0be55a03a9
commit
db9875a84b
3 changed files with 128 additions and 138 deletions
|
|
@ -767,26 +767,26 @@ export async function changeUserPassword(userId: string, newPassword: string) {
|
|||
// Function to reset password
|
||||
export async function resetPassword(username: string) {
|
||||
try {
|
||||
if (!API_KEY || !AUTH_ACCOUNT_SECRET) {
|
||||
throw new Error("KC_CLIENT_ID and KC_SECRET are required to used this feature.");
|
||||
}
|
||||
const body = new URLSearchParams();
|
||||
body.append("client_id", "gettoken");
|
||||
body.append("client_secret", AUTH_ACCOUNT_SECRET?.toString());
|
||||
body.append("grant_type", "client_credentials");
|
||||
const tokenResponse = await fetch(`${process.env.KC_URL}/realms/${process.env.KC_REALMS}/protocol/openid-connect/token`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
api_key: API_KEY,
|
||||
},
|
||||
body: body
|
||||
});
|
||||
if (!tokenResponse.ok) {
|
||||
throw new Error("Failed to get admin token");
|
||||
}
|
||||
const tokenData = await tokenResponse.json();
|
||||
const adminToken = tokenData.access_token;
|
||||
// if (!API_KEY || !AUTH_ACCOUNT_SECRET) {
|
||||
// throw new Error("KC_CLIENT_ID and KC_SECRET are required to used this feature.");
|
||||
// }
|
||||
// const body = new URLSearchParams();
|
||||
// body.append("client_id", "gettoken");
|
||||
// body.append("client_secret", AUTH_ACCOUNT_SECRET?.toString());
|
||||
// body.append("grant_type", "client_credentials");
|
||||
// const tokenResponse = await fetch(`${process.env.KC_URL}/realms/${process.env.KC_REALMS}/protocol/openid-connect/token`, {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// "Content-Type": "application/x-www-form-urlencoded",
|
||||
// api_key: API_KEY,
|
||||
// },
|
||||
// body: body
|
||||
// });
|
||||
// if (!tokenResponse.ok) {
|
||||
// throw new Error("Failed to get admin token");
|
||||
// }
|
||||
// const tokenData = await tokenResponse.json();
|
||||
// const adminToken = tokenData.access_token;
|
||||
|
||||
const users = await fetch(`${KC_URL}/admin/realms/${KC_REALMS}/users?email=${encodeURIComponent(username)}`, {
|
||||
headers: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue