Skip to content

Commit 681c4d4

Browse files
Separate authz attributes
1 parent e7f8215 commit 681c4d4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/workos/directory_user.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ def initialize(json)
4848
# rubocop:enable Metrics/AbcSize
4949

5050
def to_json(*)
51+
base_attributes.
52+
merge(authorization_attributes)
53+
end
54+
55+
private
56+
57+
def base_attributes
5158
{
5259
id: id,
5360
directory_id: directory_id,
@@ -61,15 +68,22 @@ def to_json(*)
6168
username: username,
6269
state: state,
6370
groups: groups,
64-
role: role,
65-
roles: roles,
6671
custom_attributes: custom_attributes,
6772
raw_attributes: raw_attributes,
6873
created_at: created_at,
6974
updated_at: updated_at,
7075
}
7176
end
7277

78+
def authorization_attributes
79+
{
80+
role: role,
81+
roles: roles,
82+
}
83+
end
84+
85+
public
86+
7387
# @deprecated Will be removed in a future major version. Use {#email} instead.
7488
def primary_email
7589
primary_email = (emails || []).find { |email| email[:primary] }

0 commit comments

Comments
 (0)