示例#1
0
        public string ChangePassword(ChangePasswordViewModel changePasswordViewModel)
        {
            Account userAccount = _accountDal.FindBy(x => x.Username == changePasswordViewModel.UserName).FirstOrDefault();

            if (userAccount != null)
            {
                string dbSalt     = userAccount.Salt;
                string dbPassword = userAccount.Password;
                string oldPass    = CommonBLL.CreatePasswordHash(changePasswordViewModel.OldPassword, dbSalt);
                if (oldPass.Equals(dbPassword))
                {
                    userAccount.Salt     = CommonBLL.CreateSalt();
                    userAccount.Password = CommonBLL.CreatePasswordHash(changePasswordViewModel.NewPassword, userAccount.Salt);
                    _accountDal.Edit(userAccount);
                    return("success");
                }
                else
                {
                    return("Old Password is not Correct");
                }
            }
            else
            {
                return("Username is not Correct");
            }
        }
示例#2
0
        public string CreateAccount(Account account)
        {
            if (_accountDal.IsExists(x => x.Email == account.Email))
            {
                return("Email Already Exists");
            }
            if (_accountDal.IsExists(x => x.Username == account.Username))
            {
                return("Username already Exists");
            }
            account.Salt     = CommonBLL.CreateSalt();
            account.Password = CommonBLL.CreatePasswordHash(account.Password, account.Salt);
            if (account.File != null)
            {
                account.ImagePath = CommonBLL.UploadImage(account.File, "DP");
            }

            account.IsActive = true;
            int returnValue = _accountDal.Insert(account);

            if (returnValue > 0)
            {
                return("Success");
            }
            return("There is some issue please try Again");
        }
示例#3
0
        public string ResetPassword(ResetPasswordViewModel resetPasswordViewModel)
        {
            Account userAccount = _accountDal.FindBy(x => x.ResetCode == resetPasswordViewModel.GUID).FirstOrDefault();

            if (userAccount != null)
            {
                userAccount.Salt      = CommonBLL.CreateSalt();
                userAccount.Password  = CommonBLL.CreatePasswordHash(resetPasswordViewModel.NewPassword, userAccount.Salt);
                userAccount.ResetCode = null;
                _accountDal.Edit(userAccount);
                return("success");
            }
            else
            {
                return("expires");
            }
        }