Skip to content

Commit ddc1949

Browse files
Add role to profile (#1137)
## Description Adds `role` attribute to the profile object. ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [X] Yes ``` [Docs PR](workos/workos#31033) If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
1 parent 6007dbe commit ddc1949

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules
33
yarn-error.log
44
lib/
55
package-lock.json
6-
.DS_Store
6+
.DS_Store
7+
yarn.lock

src/sso/__snapshots__/sso.spec.ts.snap

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ exports[`SSO SSO getProfileAndToken with all information provided sends a reques
4848
],
4949
"last_name": "bar",
5050
},
51+
"role": {
52+
"slug": "admin",
53+
},
5154
}
5255
`;
5356

@@ -78,5 +81,8 @@ exports[`SSO SSO getProfileAndToken without a groups attribute sends a request t
7881
"first_name": "foo",
7982
"last_name": "bar",
8083
},
84+
"role": {
85+
"slug": "admin",
86+
},
8187
}
8288
`;

src/sso/interfaces/profile.interface.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { RoleResponse } from '../../roles/interfaces';
12
import { ConnectionType } from './connection-type.enum';
23

34
export interface Profile {
@@ -9,6 +10,7 @@ export interface Profile {
910
email: string;
1011
firstName?: string;
1112
lastName?: string;
13+
role?: RoleResponse;
1214
groups?: string[];
1315
rawAttributes?: { [key: string]: any };
1416
}
@@ -22,6 +24,7 @@ export interface ProfileResponse {
2224
email: string;
2325
first_name?: string;
2426
last_name?: string;
27+
role?: RoleResponse;
2528
groups?: string[];
2629
raw_attributes?: { [key: string]: any };
2730
}

src/sso/serializers/profile.serializer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const deserializeProfile = (profile: ProfileResponse): Profile => ({
99
email: profile.email,
1010
firstName: profile.first_name,
1111
lastName: profile.last_name,
12+
role: profile.role,
1213
groups: profile.groups,
1314
rawAttributes: profile.raw_attributes,
1415
});

src/sso/sso.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ describe('SSO', () => {
209209
210210
first_name: 'foo',
211211
last_name: 'bar',
212+
role: {
213+
slug: 'admin',
214+
},
212215
groups: ['Admins', 'Developers'],
213216
raw_attributes: {
214217
@@ -247,6 +250,9 @@ describe('SSO', () => {
247250
248251
first_name: 'foo',
249252
last_name: 'bar',
253+
role: {
254+
slug: 'admin',
255+
},
250256
raw_attributes: {
251257
252258
first_name: 'foo',
@@ -282,6 +288,9 @@ describe('SSO', () => {
282288
283289
first_name: 'foo',
284290
last_name: 'bar',
291+
role: {
292+
slug: 'admin',
293+
},
285294
groups: ['Admins', 'Developers'],
286295
raw_attributes: {
287296

0 commit comments

Comments
 (0)