Skip to content
Snippets Groups Projects
Commit d1e50f2e authored by farhatahmad's avatar farhatahmad Committed by Jesus Federico
Browse files

GRN2-213: Cleaned up omniauth user create (#682)

* Fixed omniauth user create

* Added readonly exception
parent 4e16e997
Branches
Tags release-2.2.2
No related merge requests found
......@@ -55,14 +55,31 @@ class User < ApplicationRecord
def from_omniauth(auth)
# Provider is the customer name if in loadbalanced config mode
provider = auth['provider'] == "bn_launcher" ? auth['info']['customer'] : auth['provider']
find_or_initialize_by(social_uid: auth['uid'], provider: provider).tap do |u|
u = find_by(social_uid: auth['uid'], provider: provider)
if ENV["MAINTENANCE_MODE"] == "readonly"
raise ActiveRecord::ReadOnlyRecord if u.nil?
return u
end
return User.create(
name: auth_name(auth),
username: auth_username(auth),
email: auth_email(auth),
social_uid: auth['uid'],
provider: provider,
image: auth_image(auth),
email_verified: true
) if u.nil?
u.name = auth_name(auth) unless u.name
u.username = auth_username(auth) unless u.username
u.email = auth_email(auth)
u.image = auth_image(auth)
u.email_verified = true
u.save!
end
u
end
private
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment