示例#1
0
        public void ChangePassword(int id, string OldPassword, string NewPassword)
        {
            if (string.IsNullOrWhiteSpace(OldPassword) || string.IsNullOrWhiteSpace(NewPassword))
            {
                throw new Exception("Şifrenizi değiştirmek için alanları doldurunuz.");
            }
            if (OldPassword == NewPassword)
            {
                throw new Exception("Eski ve yeni şifre aynı olamaz");
            }
            User user  = Get(id);
            bool check = PasswordHelperBLL.VerifyPasswordHash(OldPassword, user.PasswordHash, user.PasswordSalt);

            if (!check)
            {
                throw new Exception("Eski şifre hatalı");
            }
            byte[] _hash;
            byte[] _salt;
            PasswordHelperBLL.CreatePasswordHash(NewPassword, out _hash, out _salt);
            user.PasswordHash = _hash;
            user.PasswordSalt = _salt;
            userDAL.Update(user);
        }
示例#2
0
        public User GetUserForLogin(string userName, string password)
        {
            User login = userDAL.Get(u => u.UserName == userName);

            if (login == null)
            {
                throw new Exception("Kullanıcı bilgileri yanlış.");
            }
            if (!login.IsActive)
            {
                throw new Exception("Hesabınızı henüz aktifleştirmediniz.Lütfen emailinize gönderilen activasyon linkine tıklayınız.");
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new Exception("Lütfen şifre giriniz.");
            }
            bool result = PasswordHelperBLL.VerifyPasswordHash(password, login.PasswordHash, login.PasswordSalt);

            if (!result)
            {
                throw new Exception("Kullanıcı bilgileri yanlış.");
            }
            return(login);
        }