Skip to content

Commit

Permalink
Merge pull request from GHSA-7cmh-wm9h-j63f
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaylorhq authored and coding-horror committed Aug 27, 2019
1 parent 03d51d6 commit 8e5a8d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ def user_found(user)
user.email_tokens.create!(email: user.email)
end

user.activate
if !user.active || !user.email_confirmed?
user.password = SecureRandom.hex
user.activate
end
user.update!(registration_ip_address: request.remote_ip) if user.registration_ip_address.blank?
end

Expand Down
18 changes: 17 additions & 1 deletion spec/requests/omniauth_callbacks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def enabled?
expect(user.email_confirmed?).to eq(true)
end

it "should activate/unstage staged user" do
it "should unstage staged user" do
user.update!(staged: true, registration_ip_address: nil)

user.reload
Expand All @@ -306,6 +306,22 @@ def enabled?
expect(user.registration_ip_address).to be_present
end

it "should activate user with matching email" do
user.update!(password: "securepassword", active: false)

user.reload
expect(user.active).to eq(false)
expect(user.confirm_password?("securepassword")).to eq(true)

get "/auth/google_oauth2/callback.json"

user.reload
expect(user.active).to eq(true)

# Delete the password, it may have been set by someone else
expect(user.confirm_password?("securepassword")).to eq(false)
end

context 'when user has second factor enabled' do
before do
user.create_totp(enabled: true)
Expand Down

1 comment on commit 8e5a8d1

@discoursereviewbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.