Beispiel #1
0
        public async Task <bool> Login(string emailrequest, string passwordrequest)
        {
            var user = await _userRepository.GetPasswordByEmail(emailrequest);

            var password = Encryptions.DecryptString(EncryptionConstants.Key, user.Password);

            if (passwordrequest != password)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public async Task <bool> ChangePassword(int id, ChangePasswordRequest request)
        {
            try
            {
                var user = await _userRepository.GetUserById(id);

                await _repositoryWrapper.BeginTransactionAsync();

                var Encrypassword = Encryptions.DecryptString(EncryptionConstants.Key, user.Password);

                if (Encrypassword == request.OldPassword)
                {
                    var encryptPassword = Encryptions.EncryptString(EncryptionConstants.Key, request.NewPassword);

                    user.Password = encryptPassword;
                }
                else
                {
                    return(false);
                }
                _repositoryWrapper.User.Updete(user);

                await _repositoryWrapper.SaveAsync();

                await _repositoryWrapper.CommitAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _repositoryWrapper.Dispose();
            }
        }