mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
FIX: send activation email if user have unconfirmed email
This commit is contained in:
parent
32d8447838
commit
7c3ae50dcd
@ -585,7 +585,7 @@ class UsersController < ApplicationController
|
||||
|
||||
session.delete(SessionController::ACTIVATE_USER_KEY)
|
||||
|
||||
if @user.active
|
||||
if @user.active && @user.email_confirmed?
|
||||
render_json_error(I18n.t('activation.activated'), status: 409)
|
||||
else
|
||||
@email_token = @user.email_tokens.unconfirmed.active.first
|
||||
|
@ -1424,9 +1424,11 @@ describe UsersController do
|
||||
context 'for an existing user' do
|
||||
let(:user) { Fabricate(:user, active: false) }
|
||||
|
||||
context 'for an activated account' do
|
||||
context 'for an activated account with email confirmed' do
|
||||
it 'fails' do
|
||||
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
|
||||
xhr :post, :send_activation_email, username: active_user.username
|
||||
|
||||
@ -1440,6 +1442,20 @@ describe UsersController do
|
||||
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
|
||||
it 'should not be valid' do
|
||||
user = Fabricate(:user)
|
||||
|
Loading…
Reference in New Issue
Block a user