Esempio n. 1
0
        public void AddUserToRoles(string account, IEnumerable <string> roleNames)
        {
            Ensure.ArgumentNotEmpty(account, nameof(account));
            Ensure.ArgumentNotEmpty(roleNames, nameof(roleNames));

            var u = _repo.GetUseByAccount(account);

            var existsRoleNames = new HashSet <string>(u.RoleNames);

            u.RoleNames = existsRoleNames.Union(new HashSet <string>(roleNames)).ToList();
            SaveUser(u);
        }
Esempio n. 2
0
        public string Login(string account, string password)
        {
            var u = _membershipRepo.GetUseByAccount(account);

            if (u == null)
            {
                return(null);
            }

            if (CryptoKit.VerifyHashedPassword(u.Password, password))
            {
                return(_tokenManager.CreateToken(account));
            }
            else
            {
                return(null);
            }
        }