FIX: Users should be able to activate their emails even if unapproved
Note in discourse `active` means "Email is active" - they still can't login until approved
This commit is contained in:
parent
104d97695d
commit
9b3b39d8a2
|
@ -24,10 +24,11 @@ class UserActivator
|
||||||
|
|
||||||
def factory
|
def factory
|
||||||
invite = Invite.find_by(email: Email.downcase(@user.email))
|
invite = Invite.find_by(email: Email.downcase(@user.email))
|
||||||
if SiteSetting.must_approve_users? && !(invite.present? && !invite.expired? && !invite.destroyed? && invite.link_valid?)
|
|
||||||
ApprovalActivator
|
if !user.active?
|
||||||
elsif !user.active?
|
|
||||||
EmailActivator
|
EmailActivator
|
||||||
|
elsif SiteSetting.must_approve_users? && !(invite.present? && !invite.expired? && !invite.destroyed? && invite.link_valid?)
|
||||||
|
ApprovalActivator
|
||||||
else
|
else
|
||||||
LoginActivator
|
LoginActivator
|
||||||
end
|
end
|
||||||
|
|
|
@ -173,7 +173,7 @@ describe UsersController do
|
||||||
|
|
||||||
context 'user is not approved' do
|
context 'user is not approved' do
|
||||||
before do
|
before do
|
||||||
Guardian.any_instance.expects(:can_access_forum?).returns(false)
|
SiteSetting.must_approve_users = true
|
||||||
EmailToken.expects(:confirm).with('asdfasdf').returns(user)
|
EmailToken.expects(:confirm).with('asdfasdf').returns(user)
|
||||||
put :perform_account_activation, token: 'asdfasdf'
|
put :perform_account_activation, token: 'asdfasdf'
|
||||||
end
|
end
|
||||||
|
@ -522,27 +522,20 @@ describe UsersController do
|
||||||
expect(session[SessionController::ACTIVATE_USER_KEY]).to be_present
|
expect(session[SessionController::ACTIVATE_USER_KEY]).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
context "and 'must approve users' site setting is enabled" do
|
context "`must approve users` site setting is enabled" do
|
||||||
before { SiteSetting.must_approve_users = true }
|
before { SiteSetting.must_approve_users = true }
|
||||||
|
|
||||||
it 'does not enqueue an email' do
|
it 'creates a user correctly' do
|
||||||
Jobs.expects(:enqueue).never
|
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
|
||||||
post_user
|
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not login the user' do
|
|
||||||
post_user
|
post_user
|
||||||
expect(session[:current_user_id]).to be_blank
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'indicates the user is not active in the response' do
|
|
||||||
post_user
|
|
||||||
expect(JSON.parse(response.body)['active']).to be_falsey
|
expect(JSON.parse(response.body)['active']).to be_falsey
|
||||||
end
|
|
||||||
|
|
||||||
it "shows the 'waiting approval' message" do
|
# should save user_created_message in session
|
||||||
post_user
|
expect(session["user_created_message"]).to be_present
|
||||||
expect(JSON.parse(response.body)['message']).to eq(I18n.t 'login.wait_approval')
|
expect(session[SessionController::ACTIVATE_USER_KEY]).to be_present
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue