Base solution for your next web application
Open Closed

AbpException User already in role 'User is not in role 'Role2'. #8041


User avatar
0
digitalcontrol created

I have user with two roles Role1 and Role2 and when I want to remove Role1 exception with message "User already in role 'User is not in role 'Role2' " is shown.

Edit: In explanation of this problem I made small mistake because role had different name and display name. The case is when I try to deletete Role1 exception message is "User already in role 'User is not in role 'Role1' ". It is same role and not have any connection to other roles.


6 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team
    • What is your product version?
    • What is your product type (Angular or MVC)?
    • What is product framework type (.net framework or .net core)?

    Can you reproduce your problem on Zero's demo site?

  • User Avatar
    0
    digitalcontrol created

    We use ASP.NET Core & Angular, version 6.4.0. Framework type .NET Core 2.2. I can not reproduce this on Zero's demo. And this not happens in every case when I want to remove a role. But some role can not be removed and this exception is thrown.

    This line throw error in UserManager.cs file:

    Implementation of base SetRoles() method is in dll file so we can not see why this error is thrown. I was hoping that You will give us a reason for base.SetRoles() method throwing this exception.

  • User Avatar
    0
    maliming created
    Support Team

    Please share the exception stack information.

  • User Avatar
    0
    digitalcontrol created

    UserFriendlyException: User already in role 'User is not in role 'Administrator'. STACK TRACE: at Abp.IdentityFramework.IdentityResultExtensions.CheckErrors(IdentityResult identityResult, ILocalizationManager localizationManager) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore\IdentityFramework\IdentityResultExtensions.cs:line 72 at PROJECT.PROJECTAppServiceBase.CheckErrors(IdentityResult identityResult) in C:\Work\PROJECT\PROJECT.Backend\src\PROJECT.Application\PROJECTAppServiceBase.cs:line 64 at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:line 68 at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.Proceed() at PROJECT.Authorization.Users.UserAppService.UpdateUserAsync(CreateOrUpdateUserInput input) in C:\Work\PROJECT\PROJECT.Backend\src\PROJECT.Application\Authorization\Users\UserAppService.cs:line 505 at Abp.Threading.InternalAsyncHelper.AwaitTaskWithPostActionAndFinally(Task actualReturnValue, Func1 postAction, Action1 finalAction) in D:\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs:line 35 at PROJECT.Authorization.Users.UserAppService.CreateOrUpdateUser(CreateOrUpdateUserInput input) in C:\Work\PROJECT\PROJECT.Backend\src\PROJECT.Application\Authorization\Users\UserAppService.cs:line 342 at lambda_method(Closure , Object ) at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()

  • User Avatar
    0
    maliming created
    Support Team

    hi @digitalcontrol This problem is very strange. Can you provide a project to reproduce the problem?

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.