class Devise::G5::AuthUserUpdater

Update user data on G5 Auth server

Attributes

model[R]

Public Class Methods

new(authenticatable_model) click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 11
def initialize(authenticatable_model)
  @model = authenticatable_model
end

Public Instance Methods

update() click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 15
def update
  update_auth_user if credentials_changed?
end

Private Instance Methods

auth_client() click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 31
def auth_client
  G5AuthenticationClient::Client.new(
    access_token: updated_by.g5_access_token
  )
end
auth_user_args() click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 41
def auth_user_args
  { id: model.uid,
    email: model.email,
    password: model.password,
    password_confirmation: model.password_confirmation }
end
credentials_changed?() click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 27
def credentials_changed?
  model.email_changed? || !model.password.blank?
end
update_auth_user() click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 21
def update_auth_user
  auth_user = auth_client.update_user(auth_user_args)
  model.clean_up_passwords
  auth_user
end
updated_by() click to toggle source
# File lib/devise_g5_authenticatable/g5/auth_user_updater.rb, line 37
def updated_by
  model.updated_by || model
end