示例#1
0
 public void Insert(User entity)
 {
     CheckUser(entity);
     Check(entity);
     CheckUserName(entity);
     IsThereAny(entity);
     byte[] _hash;
     byte[] _salt;
     PasswordHelperBLL.CreatePasswordHash(entity.Password, out _hash, out _salt);
     entity.PasswordHash = _hash;
     entity.PasswordSalt = _salt;
     userDAL.Add(entity);
 }
示例#2
0
        public void ResetPassword(int uid, string password)
        {
            User user = Get(uid);

            if (user == null)
            {
                throw new Exception("Kullanıcı bulunamadığı için şifre değiştirilemiyor daha sonra tekrar deneyiniz.");
            }
            byte[] _hash;
            byte[] _salt;
            PasswordHelperBLL.CreatePasswordHash(password, out _hash, out _salt);
            user.PasswordHash = _hash;
            user.PasswordSalt = _salt;
            userDAL.Update(user);
        }
示例#3
0
 public void Update(User entity)
 {
     Check(entity);
     //CheckUser(entity);
     CheckUserUpdate(entity);
     CheckUserName(entity);
     if (!string.IsNullOrWhiteSpace(entity.Password))
     {
         byte[] _hash;
         byte[] _salt;
         PasswordHelperBLL.CreatePasswordHash(entity.Password, out _hash, out _salt);
         entity.PasswordHash = _hash;
         entity.PasswordSalt = _salt;
     }
     userDAL.Update(entity);
 }
示例#4
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);
        }
示例#5
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);
        }