addRole User

This commit is contained in:
Bright 2024-05-30 17:52:31 +07:00
parent ef4d34d333
commit 7af21b6fe2

View file

@ -79,6 +79,7 @@ export class KeycloakController extends Controller {
firstName?: string; firstName?: string;
lastName?: string; lastName?: string;
email?: string; email?: string;
roles?: string[];
}, },
) { ) {
const userId = await createUser(body.username, body.password, { const userId = await createUser(body.username, body.password, {
@ -128,7 +129,10 @@ export class KeycloakController extends Controller {
// }); // });
// io.getInstance()?.emit("FolderCreate", folderData); // io.getInstance()?.emit("FolderCreate", folderData);
const _roles = {
role: body.roles || [],
};
const addRole = await this.addRole(userId, _roles);
return userId; return userId;
} }
@ -142,7 +146,8 @@ export class KeycloakController extends Controller {
firstName?: string; firstName?: string;
lastName?: string; lastName?: string;
email?: string; email?: string;
attributes?: object attributes?: object;
// roles?: string[];
}, },
) { ) {
// return await editUser(userId, body); // return await editUser(userId, body);
@ -150,6 +155,10 @@ export class KeycloakController extends Controller {
if (typeof chkUpdate !== "boolean") { if (typeof chkUpdate !== "boolean") {
throw new Error(chkUpdate.errorMessage); throw new Error(chkUpdate.errorMessage);
} }
// const _rolesUpdate = {
// role: body.roles || [],
// };
// const addRole = await this.addRole(userId, _rolesUpdate);
return chkUpdate return chkUpdate
} }