Skip to content

Commit

Permalink
make email the primary lookup criteria for a signin
Browse files Browse the repository at this point in the history
  • Loading branch information
thommahoney committed May 24, 2021
1 parent 7b50308 commit a498eef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ class User < ApplicationRecord
attr_accessor :pending_invite_email

def self.from_omniauth(auth, invitation_email=nil)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
where(email: invitation_email || auth['info']['email']).first_or_create do |user|
uid = auth.uid
provider = auth.provider
password = Devise.friendly_token[0,20]
user.name = auth['info']['name'] if user.name.blank?
user.email = invitation_email || auth['info']['email'] || '' if user.email.blank?
user.password = password
user.password_confirmation = password
if !user.confirmed? && invitation_email.present? && user.email == invitation_email
Expand Down

0 comments on commit a498eef

Please sign in to comment.