Пример #1
0
        public int ValidateUserChangePassword(UserChangePasswordViewModel objEntity)
        {
            int result = 0;
            AccountRepository objAccountRepository = new AccountRepository();
            var objUserRepository = new UserRepository();
            var objLoginUserViewModel = objAccountRepository.GetUserDetailsforLogin(UserFlags.UserSignIn.GetHashCode(), new UserLoginViewModel() { UserEmail = objEntity.UserEmail });

            if (objLoginUserViewModel != null)
            {
                if (PasswordHelpers.Validate(objLoginUserViewModel.Password, objLoginUserViewModel.PasswordSalt, objEntity.NewPassword))
                {
                    result = ResultFlags.OldPasswordMismatch.GetHashCode();

                }
                else
                {
                    PasswordHelpers.HashedPassword objHashedPassword = PasswordHelpers.Generate(objEntity.NewPassword);
                    var objNewUserViewModel = new UserViewModel()
                    {
                        UserId = SessionWrapper.UserAccount.UserId,
                        UserEmail = SessionWrapper.UserAccount.UserEmail,
                        PasswordSalt = objHashedPassword.Salt,
                        Password = objHashedPassword.Password
                    };

                    objNewUserViewModel = objUserRepository.Update(UserFlags.UpdatePasswordByID.GetHashCode(), objNewUserViewModel);
                    result = objNewUserViewModel.Result;

                }

            }

            return result;
        }
Пример #2
0
        public int ValidateUser(UserLoginViewModel objEntity)
        {
            int isResult = LoginResultEnum.Failure.GetHashCode();
            AccountRepository objAccountRepository = new AccountRepository();
            var objUserViewModel = objAccountRepository.GetUserDetailsforLogin(UserFlags.UserSignIn.GetHashCode(), objEntity);
            if (objUserViewModel != null)
            {
                if (objUserViewModel.RoleId == RoleUserDefinedEnum.Admin.GetHashCode())
                {

                    if (PasswordHelpers.Validate(objUserViewModel.Password, objUserViewModel.PasswordSalt, objEntity.Password))
                    {
                        isResult = AccountRepository.Login(objUserViewModel);

                    }
                }
                else
                {
                    isResult = LoginResultEnum.Unauthorized.GetHashCode();
                }

            }

            return isResult;
        }