Skip to content

Commit

Permalink
[STORY-1200] Add User role (#417)
Browse files Browse the repository at this point in the history
* Add role attribute to User model

* Add available user roles listing endpoint
  • Loading branch information
TheoPouletSouchard authored Jan 9, 2025
1 parent 3df5b88 commit 15ed05e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ export class Users {
.post(`/users/delete/${deletionId}/confirm`, { deletion: params }),
);
}

/**
* List all known roles.
*/
roles(): Promise<string[]> {
return unpackData(
this._client.authApiClient().get("/users/roles"),
"roles",
);
}
}

export default Users;
1 change: 1 addition & 0 deletions src/models/auth/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface User {
company: string | null;
location: string | null;
fullname: string;
role: string | null;

/** Github profile of the user */
github: GithubProfile;
Expand Down
11 changes: 11 additions & 0 deletions test/Users/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@ describe("Users#confirmAccountDeletion", () => {
},
);
});

describe("Users#roles", () => {
testGetter(
"https://auth.scalingo.com/v1/users/roles",
null,
"roles",
(client) => {
return new Users(client).roles();
},
);
});

0 comments on commit 15ed05e

Please sign in to comment.