Merge pull request #4767 from techAPJ/activate-account
FIX: send activation email if user have unconfirmed email address
This commit is contained in:
commit
82c0f5f587
|
@ -585,7 +585,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
session.delete(SessionController::ACTIVATE_USER_KEY)
|
session.delete(SessionController::ACTIVATE_USER_KEY)
|
||||||
|
|
||||||
if @user.active
|
if @user.active && @user.email_confirmed?
|
||||||
render_json_error(I18n.t('activation.activated'), status: 409)
|
render_json_error(I18n.t('activation.activated'), status: 409)
|
||||||
else
|
else
|
||||||
@email_token = @user.email_tokens.unconfirmed.active.first
|
@email_token = @user.email_tokens.unconfirmed.active.first
|
||||||
|
|
|
@ -1424,9 +1424,11 @@ describe UsersController do
|
||||||
context 'for an existing user' do
|
context 'for an existing user' do
|
||||||
let(:user) { Fabricate(:user, active: false) }
|
let(:user) { Fabricate(:user, active: false) }
|
||||||
|
|
||||||
context 'for an activated account' do
|
context 'for an activated account with email confirmed' do
|
||||||
it 'fails' do
|
it 'fails' do
|
||||||
active_user = Fabricate(:user, active: true)
|
active_user = Fabricate(:user, active: true)
|
||||||
|
email_token = active_user.email_tokens.create(email: active_user.email).token
|
||||||
|
EmailToken.confirm(email_token)
|
||||||
session[SessionController::ACTIVATE_USER_KEY] = active_user.id
|
session[SessionController::ACTIVATE_USER_KEY] = active_user.id
|
||||||
xhr :post, :send_activation_email, username: active_user.username
|
xhr :post, :send_activation_email, username: active_user.username
|
||||||
|
|
||||||
|
@ -1440,6 +1442,20 @@ describe UsersController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'for an activated account with unconfirmed email' do
|
||||||
|
it 'should send an email' do
|
||||||
|
unconfirmed_email_user = Fabricate(:user, active: true)
|
||||||
|
unconfirmed_email_user.email_tokens.create(email: unconfirmed_email_user.email)
|
||||||
|
session[SessionController::ACTIVATE_USER_KEY] = unconfirmed_email_user.id
|
||||||
|
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
|
||||||
|
xhr :post, :send_activation_email, username: unconfirmed_email_user.username
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
expect(session[SessionController::ACTIVATE_USER_KEY]).to eq(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'when user does not have a valid session' do
|
describe 'when user does not have a valid session' do
|
||||||
it 'should not be valid' do
|
it 'should not be valid' do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
|
Loading…
Reference in New Issue