mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 15:53:41 +08:00
FIX: When activating via omniauth, create tokens after password reset
Resetting a password invalidates all email tokens, so we need to create the tokens after the password reset.
This commit is contained in:
parent
3b9e8a0849
commit
51b7f4d900
|
@ -121,15 +121,15 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||||
user.unstage
|
user.unstage
|
||||||
user.save
|
user.save
|
||||||
|
|
||||||
# ensure there is an active email token
|
if !user.active || !user.email_confirmed?
|
||||||
|
user.update!(password: SecureRandom.hex)
|
||||||
|
|
||||||
|
# Ensure there is an active email token
|
||||||
unless EmailToken.where(email: user.email, confirmed: true).exists? ||
|
unless EmailToken.where(email: user.email, confirmed: true).exists? ||
|
||||||
user.email_tokens.active.where(email: user.email).exists?
|
user.email_tokens.active.where(email: user.email).exists?
|
||||||
|
|
||||||
user.email_tokens.create!(email: user.email)
|
user.email_tokens.create!(email: user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
if !user.active || !user.email_confirmed?
|
|
||||||
user.update!(password: SecureRandom.hex)
|
|
||||||
user.activate
|
user.activate
|
||||||
end
|
end
|
||||||
user.update!(registration_ip_address: request.remote_ip) if user.registration_ip_address.blank?
|
user.update!(registration_ip_address: request.remote_ip) if user.registration_ip_address.blank?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user