/// <summary> /// Gets roles of a user. /// </summary> /// <param name="userId"></param> /// <returns></returns> public async Task <string[]> GetUserRoles(Guid userId) { return((await _identityUserAppService.GetRolesAsync(userId)) .Items .Select(r => r.Name) .ToArray()); }
public async Task GetRolesAsync() { //Arrange var johnNash = GetUser("john.nash"); //Act var result = await _userAppService.GetRolesAsync(johnNash.Id); //Assert result.Items.Count.ShouldBe(2); result.Items.ShouldContain(r => r.Name == "moderator"); result.Items.ShouldContain(r => r.Name == "supporter"); }
public async Task <IActionResult> Info() { var profile = await _profileAppService.GetAsync(); //var user = await _userAppService.GetAsync(CurrentUser.GetId()); var roles = await _userAppService.GetRolesAsync(CurrentUser.GetId()); var auth = await GetAuthConfigAsync(); var data = new Dictionary <string, object>(3); data.Add("profile", profile); data.Add("roles", roles.Items); data.Add("auth", auth); return(Json(new { code = 1, data = data })); }
public virtual Task <ListResultDto <IdentityRoleDto> > GetRolesAsync(Guid id) { return(_userAppService.GetRolesAsync(id)); }
public async Task <string[]> GetRolesAsync(Guid userId) { var output = await _userAppService.GetRolesAsync(userId).ConfigureAwait(false); return(output.Items.Select(r => r.Name).ToArray()); }
public async Task <ListResultDto <IdentityRoleDto> > GetRoleByUserId(Guid userId) { return(await _identityUserAppService.GetRolesAsync(userId)); }
public virtual async Task <ListResult <IdentityRoleDto> > GetRolesAsync(string id) { var result = await _userAppService.GetRolesAsync(id.ToGuid()); return(new ListResult <IdentityRoleDto>(result.Items)); }