예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public async Task <User> ReturnCheckEmailAndPasswordAsync(string email, string password)
        {
            DESHelp dESHelp      = new DESHelp();
            var     passwordHash = dESHelp.Encrypt(password);
            var     Checkresult  = await GetAsync(x => x.Email == email && x.PasswordHash == passwordHash);

            return(Checkresult);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public async Task <RegisterResult> CreateUserAsync(User user, string password)
        {
            DESHelp dESHelp = new DESHelp();

            user.PasswordHash = dESHelp.Encrypt(password);
            var result = await SaveAsync(user);

            if (result)
            {
                return(RegisterResult.Success);
            }
            return(RegisterResult.Failed);
        }
예제 #3
0
        /// <summary>
        /// 验证用户
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private async Task <ClaimsIdentity> GetIdentity(string username, string password)
        {
            DESHelp dESHelp      = new DESHelp();
            var     passwordHash = dESHelp.Encrypt(password);
            //var isValidated = await _repository.GetAsync(x => x.Email == username && x.PasswordHash == passwordHash);
            var isValidated = true;

            if (isValidated)
            {
                return(await Task.FromResult(new ClaimsIdentity(new System.Security.Principal.GenericIdentity(username, "Token"), new Claim[] { })));
            }
            return(await Task.FromResult <ClaimsIdentity>(null));
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public async Task <SignInResult> CheckEmailAndPasswordAsync(string email, string password)
        {
            DESHelp dESHelp      = new DESHelp();
            var     passwordHash = dESHelp.Encrypt(password);
            var     Checkresult  = await LoadListAllAsync(x => x.Email == email && x.PasswordHash == passwordHash);

            if (Checkresult.Count > 0)
            {
                return(SignInResult.Success);
            }
            else
            {
                return(SignInResult.Failed);
            }
        }