FIX: do not create new email token if there already exists a confirmed one

This commit is contained in:
Arpit Jalan 2017-09-13 17:34:01 +05:30
parent 195982fd41
commit 4e49b3b140
1 changed files with 1 additions and 1 deletions

View File

@ -115,7 +115,7 @@ class Users::OmniauthCallbacksController < ApplicationController
if @auth_result.email_valid && @auth_result.email == user.email
user.update!(staged: false)
# ensure there is an active email token
user.email_tokens.create(email: user.email) unless user.email_tokens.active.where(email: user.email).exists?
user.email_tokens.create(email: user.email) unless EmailToken.where(email: user.email, confirmed: true).present? || user.email_tokens.active.where(email: user.email).exists?
user.activate
end