예제 #1
0
 /// <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");
        }
예제 #3
0
        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 }));
        }
예제 #4
0
 public virtual Task <ListResultDto <IdentityRoleDto> > GetRolesAsync(Guid id)
 {
     return(_userAppService.GetRolesAsync(id));
 }
예제 #5
0
        public async Task <string[]> GetRolesAsync(Guid userId)
        {
            var output = await _userAppService.GetRolesAsync(userId).ConfigureAwait(false);

            return(output.Items.Select(r => r.Name).ToArray());
        }
예제 #6
0
 public async Task <ListResultDto <IdentityRoleDto> > GetRoleByUserId(Guid userId)
 {
     return(await _identityUserAppService.GetRolesAsync(userId));
 }
예제 #7
0
        public virtual async Task <ListResult <IdentityRoleDto> > GetRolesAsync(string id)
        {
            var result = await _userAppService.GetRolesAsync(id.ToGuid());

            return(new ListResult <IdentityRoleDto>(result.Items));
        }