Skip to content

Commit

Permalink
Fix login failure with a user who email address already exists, but d…
Browse files Browse the repository at this point in the history
…ifferent uid
  • Loading branch information
eisuke committed Mar 10, 2017
1 parent 8832fe1 commit 01cf9a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/kuroko2/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ class Kuroko2::User < Kuroko2::ApplicationRecord
before_create :set_gravatar_image

def self.find_or_create_user(uid, attributes)
find_or_create_by(uid: uid) do |user|
(find_by(uid: uid) || find_by(email: attributes[:email]) || new(uid: uid)).tap do |user|
user.uid = uid
user.name = attributes[:name]
user.email = attributes[:email]
user.first_name = attributes[:first_name]
user.last_name = attributes[:last_name]
user.save!
end
end

Expand Down

0 comments on commit 01cf9a0

Please sign in to comment.