예제 #1
0
        private async Task TryGetUser(ClaimsPrincipal subject, Func <UserItemDto, Task> process)
        {
            var sub = subject?.GetSubjectId();

            if (sub == null)
            {
                throw new Exception("No sub claim present");
            }

            var builder = new ServiceUriBuilder(Sso.Remoting.Constants.ServiceName_ProfileStateService);

            var itemId = new ItemId(new Guid(sub));

            UserItemDto user = null;
            await StopwatchLog.TrackFuncAsync(async() => user = await _remoteServiceClient.CreateUserAppService(itemId).FindByIdAsync(itemId));

            if (user == null)
            {
                ServiceEventSource.Current.Message("No user found matching subject Id: {0}", sub);
            }
            else
            {
                await process(user);
            }
        }
예제 #2
0
        private async Task <string> GetRoles(ItemId userId)
        {
            List <RoleDto> _userRoles = null;
            await StopwatchLog.TrackFuncAsync(async() => _userRoles = await _remoteServiceClient.CreateUserRoleAppService().FindRolesByUserIdAsync(userId.ToString()));

            if (_userRoles.Count > 0)
            {
                return(string.Join(",", _userRoles.Select(p => p.ID)));
            }
            return(null);
        }