Module: PublishingPlatform::SSO::User::ClassMethods

Defined in:
lib/publishing_platform_sso/user.rb

Instance Method Summary collapse

Instance Method Details

#find_for_oauth(auth_hash) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/publishing_platform_sso/user.rb', line 35

def find_for_oauth(auth_hash)
  user_params = PublishingPlatform::SSO::User.user_params_from_auth_hash(auth_hash.to_hash)
  user = where(uid: user_params["uid"]).first ||
    where(email: user_params["email"]).first

  if user
    user.update!(user_params)
    user
  else # Create a new user.
    create!(user_params)
  end
end