asp.net core - UserManager.RemoveFromRoleAsync() not removing from role -


okay, weird.

if user.isinrole("admin") returns true, user indeed in "admin" role.

however, when try remove them role, identityresult usermanager.removefromroleasync() claims user not in role.

i attempt remove role so:

if (user.isinrole("admin")) {     var user = await _usermanager.findbynameasync(user.identity.name);     var result = await _usermanager.removefromroleasync(user, "admin"); } 

i have own custom userstore implements iuserrole interface (against marten-based postgresql db). .removefromroleasync method looks this:

public async task removefromroleasync(tuser user, string normalizedrolename, cancellationtoken cancellationtoken) {     cancellationtoken.throwifcancellationrequested();      if (user == null)     {         throw new argumentnullexception(nameof(user));     }      var role = await roles.firstordefaultasync(r => r.normalizedname == normalizedrolename, cancellationtoken);      if (role != null)     {         user.roles.remove(role.name);     } } 

it gets weirder. if put breakpoints .removefromroleasync() method , debug, breakpoints never hit when attempting remove role. it's if has determined user not in role before tries fire .removefromroleasync() method.

so if know they're in role, yet method isn't firing because usermanager believes they're not in role, how should remove them role?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -