Skip to content

Commit

Permalink
fix: check userRole when creating SAML user
Browse files Browse the repository at this point in the history
  • Loading branch information
jakerenzella committed Jan 17, 2022
1 parent 9e7fc78 commit aabea8f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/authentication_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class AuthenticationApi < Grape::API
User.find_by_username(email[/(.*)@/, 1]) ||
User.find_by(email: email) ||
User.find_or_create_by(login_id: login_id) do |new_user|
role = attributes.fetch(/role/) || Role.student.id
role_response = attributes.fetch(/role/) || attributes.fetch(/userRole/)
role = role_response.include?('Staff') ? Role.tutor.id : Role.student.id
first_name = (attributes.fetch(/givenname/) || attributes.fetch(/cn/)).capitalize
last_name = attributes.fetch(/surname/).capitalize
username = email.split('@').first
Expand Down

0 comments on commit aabea8f

Please sign in to comment.