This forum is not used anymore. Please ask new questions to Stack Overflow: https://stackoverflow.com/questions/tag ... ort=newest (use aspnetboilerplate tag).
User avatar
By AliNM
#6456 This code returns exception and logs an error in the browser for invalid Login credentials.

private async Task<AbpUserManager<Tenant, Role, User>.AbpLoginResult> GetLoginResultAsync(string usernameOrEmailAddress, string password, string tenancyName)
{
var loginResult = await _userManager.LoginAsync(usernameOrEmailAddress, password, tenancyName);
switch (loginResult.Result)
{
case AbpLoginResultType.Success:
return loginResult;
default:
throw CreateExceptionForFailedLoginAttempt(loginResult.Result, usernameOrEmailAddress, tenancyName);
}
}


In my case, i want to handle exception in javascript and show an error message

$('#LoginButton').click(function (e) {
e.preventDefault();
abp.ui.setBusy(
$('#LoginArea'),
abp.ajax({
url: abp.appPath + 'Account/Login',
type: 'POST',
data: JSON.stringify({
tenancyName: $('#TenancyName').val(),
usernameOrEmailAddress: $('#EmailAddressInput').val(),
password: $('#PasswordInput').val(),
rememberMe: $('#RememberMeInput').is(':checked'),
returnUrlHash: $('#ReturnUrlHash').val()
})
})
);
});

What can I do to achieve invalid credentials error message?