Greetings Programs!
I have been working on migrating a 4.x MVC application to an 8.4 Angular + Core application.
I have LDAP enabled with multi-tenancy and I moved all the users over along with their roles (accounting for column changes).
When I try to log in using credentials ( testing with two users), I receive the "Email 'myemail' is already taken" error. It seems like it couldn't find the user and is trying to add the user instead of logging in.
The log in production doesn't seem to be showing the error but in dev, I get the output below.
Thanks,
Wg
Mvc.ExceptionHandling.AbpExceptionFilter - Email '[email protected]' is already taken.
Abp.UI.UserFriendlyException: Email '[email protected]' is already taken.
at Abp.Authorization.Users.AbpUserManager`2.CheckDuplicateUsernameOrEmailAddressAsync(Nullable`1 expectedUserId, String userName, String emailAddress)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at Abp.Authorization.Users.AbpUserManager`2.CreateAsync(TUser user)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at Abp.Authorization.AbpLogInManager`3.TryLoginFromExternalAuthenticationSourcesAsync(String userNameOrEmailAddress, String plainPassword, TTenant tenant)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at Abp.Authorization.AbpLogInManager`3.LoginAsyncInternal(String userNameOrEmailAddress, String plainPassword, String tenancyName, Boolean shouldLockout)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at Abp.Authorization.AbpLogInManager`3.LoginAsync(String userNameOrEmailAddress, String plainPassword, String tenancyName, Boolean shouldLockout)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at MyAppInc.Web.Controllers.TokenAuthController.GetLoginResultAsync(String usernameOrEmailAddress, String password, String tenancyName) in C:\Projects\Core + Angular - 8.4\MyAppInc\aspnet-core\src\MyAppInc.Web.Core\Controllers\TokenAuthController.cs:line 652
at MyAppInc.Web.Controllers.TokenAuthController.Authenticate(AuthenticateModel model) in C:\Projects\Core + Angular - 8.4\MyAppInc\aspnet-core\src\MyAppInc.Web.Core\Controllers\TokenAuthController.cs:line 138
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
11 Answer(s)
-
0
I found that I was able to log in with the email address and after that, I was able to log in normally with the username.
Is there something I can update so this isn't necessary?
-
0
Hi @wizgod
What is your ABP Nuget package version ?
-
0
Hi @ismcagdas,
Abp and Abp.* packages are v5.4.0 with Abp.AspNetZeroCore and Abp.AspNetZeroCore.Web being v2.0.0.
-
0
Hi @ismcagdas,
I added that code and overrode the method in LogInManager.
At:
var user = await UserManager.FindByNameOrEmailAsync(tenantId, userNameOrEmailAddress);
- It can't find the user when userNameOrEmailAddress is the username; the value returns null (the correct tenantId is passed).
- It does find the user if the email address is used.
- If I switch back to loging in with the username after using the email address, it finds the user.
When it's null,it trys to create the object and the "Email is already taken" exception is thrown at:
await UserManager.CreateAsync(user);
-
0
Hi,
Could you do the same override in UserManager for this method https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore/Authorization/Users/AbpUserManager.cs#L609 and see which user it finds here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore/Authorization/Users/AbpUserManager.cs#L617
-
0
Hi @ismcagdas,
Will do. I'll let you know in about 10 days; tied up till then.
Thanks,
Wg
-
0
Thanks :)
-
0
Hi @ismcagdas,
Has that method changed for 8.5.0?
It's saying that _passwordHasher is not accessable because it's private.
Thanks,
Wg
-
0
@ismcagdas, I've figured it out; it was an oversight on my part.
When I was migrating the users, I was setting the new NormalizedUserName column with UPPER(Name + ' ' + Surname) instead of UPPER(UserName).
Thanks,
Wg
-
0
Thanks @wizgod :)