mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 20:18:23 -05:00
FIX: always unstage users when they log in
This commit is contained in:
@@ -125,7 +125,8 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||
|
||||
# automatically activate/unstage any account if a provider marked the email valid
|
||||
if @auth_result.email_valid && @auth_result.email == user.email
|
||||
user.update!(staged: false)
|
||||
user.unstage
|
||||
user.save
|
||||
|
||||
# ensure there is an active email token
|
||||
unless EmailToken.where(email: user.email, confirmed: true).exists? ||
|
||||
|
||||
@@ -57,7 +57,8 @@ class DiscourseSingleSignOn < SingleSignOn
|
||||
end
|
||||
|
||||
# ensure it's not staged anymore
|
||||
user.staged = false
|
||||
user.unstage
|
||||
user.save
|
||||
|
||||
# if the user isn't new or it's attached to the SSO record we might be overriding username or email
|
||||
unless user.new_record?
|
||||
|
||||
+8
-5
@@ -269,15 +269,18 @@ class User < ActiveRecord::Base
|
||||
user
|
||||
end
|
||||
|
||||
def unstage
|
||||
self.staged = false
|
||||
self.custom_fields[FROM_STAGED] = true
|
||||
self.notifications.destroy_all
|
||||
DiscourseEvent.trigger(:user_unstaged, self)
|
||||
end
|
||||
|
||||
def self.unstage(params)
|
||||
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
|
||||
params.each { |k, v| user.send("#{k}=", v) }
|
||||
user.staged = false
|
||||
user.active = false
|
||||
user.custom_fields[FROM_STAGED] = true
|
||||
user.notifications.destroy_all
|
||||
|
||||
DiscourseEvent.trigger(:user_unstaged, user)
|
||||
user.unstage
|
||||
end
|
||||
user
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user