Skip to content

Commit

Permalink
Add role to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
kendallstrautman committed Oct 2, 2024
1 parent bd9d9ef commit a3eb679
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/workos/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module WorkOS
class Profile
include HashProvider

attr_accessor :id, :email, :first_name, :last_name, :groups, :organization_id,
attr_accessor :id, :email, :first_name, :last_name, :role, :groups, :organization_id,
:connection_id, :connection_type, :idp_id, :raw_attributes

def initialize(profile_json)
Expand All @@ -19,6 +19,7 @@ def initialize(profile_json)
@email = hash[:email]
@first_name = hash[:first_name]
@last_name = hash[:last_name]
@role = hash[:role]
@groups = hash[:groups]
@organization_id = hash[:organization_id]
@connection_id = hash[:connection_id]
Expand All @@ -37,6 +38,7 @@ def to_json(*)
email: email,
first_name: first_name,
last_name: last_name,
role: role,
groups: groups,
organization_id: organization_id,
connection_id: connection_id,
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/workos/sso_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@
id: 'prof_01EEJTY9SZ1R350RB7B73SNBKF',
idp_id: '116485463307139932699',
last_name: 'Loblaw',
role: {
slug: 'member',
},
groups: nil,
organization_id: 'org_01FG53X8636WSNW2WEKB2C31ZB',
raw_attributes: {
Expand Down Expand Up @@ -373,6 +376,9 @@
id: 'prof_01DRA1XNSJDZ19A31F183ECQW5',
idp_id: '00u1klkowm8EGah2H357',
last_name: 'Demo',
role: {
slug: 'admin',
},
groups: %w[Admins Developers],
organization_id: 'org_01FG53X8636WSNW2WEKB2C31ZB',
raw_attributes: {
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/vcr_cassettes/sso/profile.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/support/profile.txt
Original file line number Diff line number Diff line change
@@ -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"}
{"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 comments on commit a3eb679

Please sign in to comment.