Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Get User Roles in WebApi

$
0
0

Hi I am testing WebApi calls and I Wanted to proble users and their roles.

I can get all roles, and user data but how can I check what roles a user has?

This is a plugin so I can not know what type of role providers a consuming project could have. COuld be Default ones, could be OWIN. Could be something different.

[HttpGet]
public IHttpActionResult GetCurrentUserData(string userName)
{
  var virtualRoleRepository = (RolesRepository ?? ServiceLocator.Current.GetInstance<IVirtualRoleRepository>()).GetAllRoles();
  var user = EPiServerProfile.Get(userName);
  //var userRoles = ?????
  if (user == null)
    return NotFound();
  return Ok(user);
}

Viewing all articles
Browse latest Browse all 6894

Trending Articles