mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:11:11 +08:00
Strip leading/trailing spaces from login
This commit is contained in:
@ -13,7 +13,7 @@ describe SessionController do
|
||||
end
|
||||
|
||||
it "raises an error when the login isn't present" do
|
||||
lambda { xhr :post, :create }.should raise_error(ActionController::ParameterMissing)
|
||||
lambda { xhr :post, :create }.should raise_error(ActionController::ParameterMissing)
|
||||
end
|
||||
|
||||
describe 'invalid password' do
|
||||
@ -72,6 +72,21 @@ describe SessionController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'login has leading and trailing space' do
|
||||
let(:username) { " #{user.username} " }
|
||||
let(:email) { " #{user.email} " }
|
||||
|
||||
it "strips spaces from the username" do
|
||||
xhr :post, :create, login: username, password: 'myawesomepassword'
|
||||
::JSON.parse(response.body)['error'].should_not be_present
|
||||
end
|
||||
|
||||
it "strips spaces from the email" do
|
||||
xhr :post, :create, login: email, password: 'myawesomepassword'
|
||||
::JSON.parse(response.body)['error'].should_not be_present
|
||||
end
|
||||
end
|
||||
|
||||
describe "when the site requires approval of users" do
|
||||
before do
|
||||
SiteSetting.expects(:must_approve_users?).returns(true)
|
||||
|
Reference in New Issue
Block a user