Skip to content

Commit

Permalink
Adds user role when logging in via shib (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Devanshu Matlawala authored Nov 24, 2020
1 parent 9951cd6 commit e37f172
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def self.from_omniauth(auth)
user.assign_attributes(display_name: auth.info.first_name, ppid: auth.uid, uid: auth.info.net_id)
# tezprox@emory.edu isn't a real email address
user.email = auth.info.net_id + '@emory.edu' unless auth.info.net_id == 'tezprox'
Avalon::RoleControls.add_user_role(user.username, 'administrator') unless Avalon::RoleControls.user_roles(user.username).include?('administrator')
user.save
user
end
Expand Down
3 changes: 2 additions & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
)
end

it "updates ppid and display_name with values from shibboleth" do
it "updates ppid and display_name and group with values from shibboleth" do
expect(user.uid).to eq auth_hash.info.net_id
expect(user.ppid).to eq auth_hash.uid
expect(user.display_name).to eq auth_hash.info.first_name
Expand All @@ -235,6 +235,7 @@
expect(user.ppid).to eq updated_auth_hash.uid
expect(user.display_name).not_to eq auth_hash.info.first_name
expect(user.display_name).to eq updated_auth_hash.info.first_name
expect(Avalon::RoleControls.user_roles(user.username)).to include('administrator')
end
end

Expand Down

0 comments on commit e37f172

Please sign in to comment.