Skip to content

Commit

Permalink
✨ Sync local authentification user with OneRoster API, #151
Browse files Browse the repository at this point in the history
Save authentication as "local " and hashed password from user.password
of OneRoster data
  • Loading branch information
kyoshizaki committed Apr 3, 2021
1 parent cb76c02 commit 46c9de3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def self.sync_roster(rusers)
rusers.each do |ru|
# Query by signin_name in consideration of the case there are users without sourcedId created before using RosterAPI
user = User.find_or_initialize_by(signin_name: ru['username'])
if user.update_attributes(sourced_id: ru['sourcedId'], authentication: 'ldap', family_name: ru['familyName'], given_name: ru['givenName'])
ids.push({id: user.id, sourced_id: user.sourced_id})
if ru['password'].empty?
user_hash = {sourced_id: ru['sourcedId'], authentication: 'ldap', family_name: ru['familyName'], given_name: ru['givenName']}
else
user_hash = {sourced_id: ru['sourcedId'], authentication: 'local', password: ru['password'], family_name: ru['familyName'], given_name: ru['givenName']}
end
ids.push({id: user.id, sourced_id: user.sourced_id}) if user.update_attributes(user_hash)
end
ids
end
Expand Down

0 comments on commit 46c9de3

Please sign in to comment.