private bool TryGetUserAccount(string userName, out UserAccountEntity account)
        {
            var context = NewContext;

            // check if user exists
            account = (from c in context.UserAccounts
                       where c.PartitionKey == userName.ToLowerInvariant() &&
                             c.RowKey == UserAccountEntity.EntityKind
                       select c).FirstOrDefault();

            return (account != null);
        }
        private bool TryGetUserAccount(string userName, out UserAccountEntity account)
        {
            var context = NewContext;

            // check if user exists
            account = (from c in context.UserAccounts
                       where c.PartitionKey == userName.ToLowerInvariant() &&
                       c.RowKey == UserAccountEntity.EntityKind
                       select c).FirstOrDefault();

            return(account != null);
        }
コード例 #3
0
        public void AddUserAccount(string userName, string passwordHash, string salt, string internalRoles)
        {
            var entity = new UserAccountEntity
            {
                PartitionKey  = userName.ToLowerInvariant(),
                RowKey        = UserAccountEntity.EntityKind,
                Kind          = UserAccountEntity.EntityKind,
                PasswordHash  = passwordHash,
                Salt          = salt,
                InternalRoles = internalRoles
            };

            AddEntity(entity, UsersTable);
        }
        public IEnumerable <string> GetRoles(string userName)
        {
            UserAccountEntity account = null;

            if (TryGetUserAccount(userName, out account))
            {
                if (!string.IsNullOrWhiteSpace(account.InternalRoles))
                {
                    var roles = account.InternalRoles.Split(',');
                    return(new List <string>(from r in roles select r));
                }
            }

            return(new string[] { });
        }
コード例 #5
0
        public void AddUserAccount(string userName, string passwordHash, string salt, string internalRoles)
        {
            var entity = new UserAccountEntity
            {
                PartitionKey = userName.ToLowerInvariant(),
                RowKey = UserAccountEntity.EntityKind,
                Kind = UserAccountEntity.EntityKind,
                PasswordHash = passwordHash,
                Salt = salt,
                InternalRoles = internalRoles
            };

            AddEntity(entity, UsersTable);
        }