-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add user and roles type refactor
- Loading branch information
Showing
24 changed files
with
168 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 20 additions & 6 deletions
26
...ges/mern-sample-app/app-node-express/test/config/__mocks__/AuthorizationRepositoryMock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
import type { AuthorizationRepository } from "../../../dist/infrastructure/repository/UserRepository"; | ||
import type { ApiKeycloakUser } from "@org/lib-api-client"; | ||
import type { KcUserRepresentation, User } from "@org/lib-api-client"; | ||
|
||
export class AuthorizationRepositoryMock implements AuthorizationRepository { | ||
static roles: Record<string, string[]> = { | ||
admin: ["admin", "user"], | ||
user: ["user"], | ||
admin: ["avr-admin", "avr-user"], | ||
user: ["avr-user"], | ||
}; | ||
|
||
static users: ApiKeycloakUser[] = [ | ||
static users: User[] = [ | ||
{ | ||
id: "1", | ||
username: "admin", | ||
enabled: true, | ||
realmRoles: ["avr-admin"], | ||
}, | ||
{ | ||
id: "2", | ||
username: "user", | ||
enabled: true, | ||
realmRoles: ["avr-user"], | ||
}, | ||
]; | ||
|
||
async findRolesByUserId(userId: string): Promise<string[]> { | ||
return await Promise.resolve(AuthorizationRepositoryMock.roles[userId] ?? []); | ||
} | ||
|
||
async findUserByUsername(username: string): Promise<ApiKeycloakUser | null> { | ||
async findUserByUsername(username: string): Promise<User | null> { | ||
return await Promise.resolve( | ||
AuthorizationRepositoryMock.users.find(user => user.username === username) ?? null, | ||
); | ||
} | ||
|
||
async findAllUsers(): Promise<ApiKeycloakUser[]> { | ||
async findAllUsers(): Promise<User[]> { | ||
return await Promise.resolve(AuthorizationRepositoryMock.users); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async createUser(_model: KcUserRepresentation): Promise<KcUserRepresentation> { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async deleteUser(_id: string): Promise<void> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/mern-sample-app/app-vite-react/src/app/components/Protect/Protect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...n-sample-app/app-vite-react/src/app/pages/admin-settings/manage-users/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./FixedBadge"; | ||
export * from "./UserCreateFormButton"; | ||
export * from "./UserForm"; |
Oops, something went wrong.