public static ChatUserContext FromClaims(IEnumerable <Claim> claims, BotOptions config) { List <Claim> claimsList = claims.ToList(); //Get id string id = UserHelper.GetBestClaimValue("id", claimsList, config.ClaimsId, true); //Get name string firstName = UserHelper.GetBestClaimValue("firstName", claimsList, config.ClaimsFirstName, true); string lastName = UserHelper.GetBestClaimValue(claimsList, config.ClaimsLastName); //Get role string role = UserHelper.GetBestClaimValue(claimsList, config.ClaimsRole); ChatUserRole roleEnum = ChatUserRole.Consumer; if (!string.IsNullOrEmpty(role) && config.ClaimsRoleAdminValues.Contains(role)) { roleEnum = ChatUserRole.Admin; } UserRoleCache.UserRoles[$"dl_{id}"] = roleEnum; var userContext = new ChatUserContext() { Id = $"dl_{id}", Name = $"{firstName} {lastName}", Role = roleEnum }; return(userContext); }
public async Task <IEnumerable <ConversationReference> > GetConversations(ChatUserRole chatUserRole) { var result = await _repoChatUserSessions.GetItemsAsync(p => p.Role == chatUserRole.ToString()); return(Mapper.Map <IEnumerable <ConversationReference> >(result)); }