Merge pull request #5419 from techAPJ/staged-ip-address
FIX: save registration_ip_address for staged users logging in via social auth
This commit is contained in:
commit
bb9281de39
|
@ -117,6 +117,7 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||||
# ensure there is an active email token
|
# ensure there is an active email token
|
||||||
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.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
|
user.activate
|
||||||
|
user.update!(registration_ip_address: request.remote_ip) if user.registration_ip_address.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
if ScreenedIpAddress.should_block?(request.remote_ip)
|
if ScreenedIpAddress.should_block?(request.remote_ip)
|
||||||
|
|
|
@ -89,6 +89,26 @@ RSpec.describe Users::OmniauthCallbacksController do
|
||||||
expect(user.email_confirmed?).to eq(true)
|
expect(user.email_confirmed?).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should activate/unstage staged user" do
|
||||||
|
user.update!(staged: true, registration_ip_address: nil)
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
expect(user.staged).to eq(true)
|
||||||
|
expect(user.registration_ip_address).to eq(nil)
|
||||||
|
|
||||||
|
events = DiscourseEvent.track_events do
|
||||||
|
get "/auth/google_oauth2/callback.json"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(events.map { |event| event[:event_name] }).to include(:user_logged_in, :user_first_logged_in)
|
||||||
|
|
||||||
|
expect(response).to be_success
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
expect(user.staged).to eq(false)
|
||||||
|
expect(user.registration_ip_address).to be_present
|
||||||
|
end
|
||||||
|
|
||||||
context 'when user has not verified his email' do
|
context 'when user has not verified his email' do
|
||||||
before do
|
before do
|
||||||
GoogleUserInfo.create!(google_user_id: '12345', user: user)
|
GoogleUserInfo.create!(google_user_id: '12345', user: user)
|
||||||
|
|
Loading…
Reference in New Issue