SECURITY: always allow staff to resend activation mails

This commit is contained in:
Sam 2017-03-13 10:32:24 -04:00
parent 1a745ca16a
commit a690121805
2 changed files with 8 additions and 2 deletions

View File

@ -571,7 +571,7 @@ class UsersController < ApplicationController
raise Discourse::NotFound unless @user raise Discourse::NotFound unless @user
if (current_user && !current_user.staff?) || if !current_user&.staff? &&
@user.id != session[SessionController::ACTIVATE_USER_KEY] @user.id != session[SessionController::ACTIVATE_USER_KEY]
raise Discourse::InvalidAccess raise Discourse::InvalidAccess

View File

@ -1423,9 +1423,15 @@ describe UsersController do
it 'should not be valid' do it 'should not be valid' do
user = Fabricate(:user) user = Fabricate(:user)
xhr :post, :send_activation_email, username: user.username xhr :post, :send_activation_email, username: user.username
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
it 'should allow staff regardless' do
log_in :admin
user = Fabricate(:user, active: false)
xhr :post, :send_activation_email, username: user.username
expect(response.status).to eq(200)
end
end end
context 'with a valid email_token' do context 'with a valid email_token' do