Commit f03700f5 authored by Douwe Maan's avatar Douwe Maan

Merge branch '39366-email-confirmation-fails' into 'master'

grab the correct username when confirming secondary email

Closes #39366

See merge request gitlab-org/gitlab-ce!15010
parents 6d7384f5 306d0302
...@@ -10,7 +10,7 @@ class ConfirmationsController < Devise::ConfirmationsController ...@@ -10,7 +10,7 @@ class ConfirmationsController < Devise::ConfirmationsController
users_almost_there_path users_almost_there_path
end end
def after_confirmation_path_for(_resource_name, resource) def after_confirmation_path_for(resource_name, resource)
# incoming resource can either be a :user or an :email # incoming resource can either be a :user or an :email
if signed_in?(:user) if signed_in?(:user)
after_sign_in(resource) after_sign_in(resource)
......
...@@ -14,6 +14,8 @@ class Email < ActiveRecord::Base ...@@ -14,6 +14,8 @@ class Email < ActiveRecord::Base
devise :confirmable devise :confirmable
self.reconfirmable = false # currently email can't be changed, no need to reconfirm self.reconfirmable = false # currently email can't be changed, no need to reconfirm
delegate :username, to: :user
def email=(value) def email=(value)
write_attribute(:email, value.downcase.strip) write_attribute(:email, value.downcase.strip)
end end
......
---
title: 'Fix bug preventing secondary emails from being confirmed'
merge_request: 15010
author:
type: fixed
...@@ -40,4 +40,12 @@ describe Email do ...@@ -40,4 +40,12 @@ describe Email do
expect(user.emails.confirmed.count).to eq 1 expect(user.emails.confirmed.count).to eq 1
end end
end end
describe 'delegation' do
let(:user) { create(:user) }
it 'delegates to :user' do
expect(build(:email, user: user).username).to eq user.username
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment