Skip to content

Commit a437b1a

Browse files
Add "role" to profile (#330)
* Add role to profile * Exclud 'it' method for max block length
1 parent bd9d9ef commit a437b1a

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Layout/LineLength:
1212
- 'VCR\.use_cassette'
1313
- '(\A|\s)/.*?/'
1414
Metrics/BlockLength:
15-
ExcludedMethods: ['describe', 'context', 'before']
15+
ExcludedMethods: ['describe', 'context', 'before', 'it']
1616
Metrics/MethodLength:
1717
Max: 30
1818
Metrics/ModuleLength:

lib/workos/profile.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module WorkOS
99
class Profile
1010
include HashProvider
1111

12-
attr_accessor :id, :email, :first_name, :last_name, :groups, :organization_id,
12+
attr_accessor :id, :email, :first_name, :last_name, :role, :groups, :organization_id,
1313
:connection_id, :connection_type, :idp_id, :raw_attributes
1414

1515
def initialize(profile_json)
@@ -19,6 +19,7 @@ def initialize(profile_json)
1919
@email = hash[:email]
2020
@first_name = hash[:first_name]
2121
@last_name = hash[:last_name]
22+
@role = hash[:role]
2223
@groups = hash[:groups]
2324
@organization_id = hash[:organization_id]
2425
@connection_id = hash[:connection_id]
@@ -37,6 +38,7 @@ def to_json(*)
3738
email: email,
3839
first_name: first_name,
3940
last_name: last_name,
41+
role: role,
4042
groups: groups,
4143
organization_id: organization_id,
4244
connection_id: connection_id,

spec/lib/workos/sso_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@
302302
id: 'prof_01EEJTY9SZ1R350RB7B73SNBKF',
303303
idp_id: '116485463307139932699',
304304
last_name: 'Loblaw',
305+
role: {
306+
slug: 'member',
307+
},
305308
groups: nil,
306309
organization_id: 'org_01FG53X8636WSNW2WEKB2C31ZB',
307310
raw_attributes: {
@@ -373,6 +376,9 @@
373376
id: 'prof_01DRA1XNSJDZ19A31F183ECQW5',
374377
idp_id: '00u1klkowm8EGah2H357',
375378
last_name: 'Demo',
379+
role: {
380+
slug: 'admin',
381+
},
376382
groups: %w[Admins Developers],
377383
organization_id: 'org_01FG53X8636WSNW2WEKB2C31ZB',
378384
raw_attributes: {

spec/support/fixtures/vcr_cassettes/sso/profile.yml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/support/profile.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"profile":{"object":"profile","id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","organization_id":"org_01FG53X8636WSNW2WEKB2C31ZB","connection_id":"conn_01EMH8WAK20T42N2NBMNBCYHAG","connection_type":"OktaSAML","last_name":"Demo","groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357","raw_attributes":{"id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","last_name":"Demo","groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357"}},"access_token":"01DVX6QBS3EG6FHY2ESAA5Q65X"}
1+
{"profile":{"object":"profile","id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","organization_id":"org_01FG53X8636WSNW2WEKB2C31ZB","connection_id":"conn_01EMH8WAK20T42N2NBMNBCYHAG","connection_type":"OktaSAML","last_name":"Demo","role":{"slug": "admin"},"groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357","raw_attributes":{"id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"[email protected]","first_name":"WorkOS","last_name":"Demo","groups":["Admins","Developers"],"idp_id":"00u1klkowm8EGah2H357"}},"access_token":"01DVX6QBS3EG6FHY2ESAA5Q65X"}

0 commit comments

Comments
 (0)