Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim whitespace from username and password during sign-in #22010

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public async override Task<SignInResult> PasswordSignInAsync(
bool isPersistent,
bool lockoutOnFailure)
{
userName = userName.Trim();
password = password.Trim();

foreach (var externalLoginProviderInfo in AbpOptions.ExternalLoginProviders.Values)
{
var externalLoginProvider = (IExternalLoginProvider)Context.RequestServices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,24 @@ public async Task Should_Not_SignIn_If_User_Not_Active()

result.ShouldBe("NotAllowed");
}

[Fact]
public async Task Should_SignIn_With_Correct_Credentials_When_Has_Spaces()
{
var result = await GetResponseAsStringAsync(
"api/signin-test/password?userName= admin &password= 1q2w3E* "
);

result.ShouldBe("Succeeded");
}

[Fact]
public async Task Should_Not_SignIn_With_Correct_Credentials_When_Has_Middle_Spaces()
{
var result = await GetResponseAsStringAsync(
"api/signin-test/password?userName=ad min&password=1q2w 3E*"
);

result.ShouldBe("Failed");
}
}
Loading