Skip to content

Commit

Permalink
fix: searching users by exact_username attribute (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSlimvReal authored Feb 8, 2024
1 parent 1135d85 commit 52cf588
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/account/account.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('AccountController', () => {
expect(res).toEqual({ roles, ...requestedUser });
expect(mockHttp.get).toHaveBeenCalledWith(
expect.stringMatching(/\/users$/),
{ params: { username: 'my-user', exact: true } },
{ params: { q: 'exact_username:my-user', exact: true } },
);
expect(mockHttp.get).toHaveBeenCalledWith(
expect.stringMatching(/\/users\/user-id\/role-mappings\/realm$/),
Expand Down
5 changes: 3 additions & 2 deletions src/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export class AccountController {
@Headers('Accept-Language') lang?: string,
) {
const user = req.user as User;
// TODO email is directly marked as verified
return this.keycloak
.updateUser(user.realm, user.sub, {
email: email,
Expand Down Expand Up @@ -165,7 +164,9 @@ export class AccountController {
): Promise<KeycloakUser> {
const user = req.user as User;
const account = await firstValueFrom(
this.keycloak.findUserBy(user.realm, { username }),
this.keycloak.findUserBy(user.realm, {
q: `exact_username:${username}`,
}),
);
const roles = await firstValueFrom(
this.keycloak.getRolesOfUser(user.realm, account.id),
Expand Down

0 comments on commit 52cf588

Please sign in to comment.