Beispiel #1
0
 /**
  * @param string $username
  * @param string $password
  * @param string $oneTimeToken
  * @param SessionInterface $session
  * @throws UserException
  * @return UserVO
  */
 public function tryLogin(string $username, string $password, string $oneTimeToken, SessionInterface $session) : UserVO
 {
     $userVo = $this->loadUser->loadUserByUsername($username);
     if (!$this->passwordHasher->verifyHash($password, $userVo->getPassword())) {
         throw new UserException('Invalid Password');
     }
     $authenticationVo = new AuthenticationDataVO($userVo, $password, $oneTimeToken);
     $this->handleLogin($session, $authenticationVo, $userVo);
     return $userVo;
 }
Beispiel #2
0
 /**
  * @param Request $request
  * @return bool
  * @throws UserException
  * @Route("/user/change_password/", name="user.change_password", methods="POST")
  */
 public function changePassword(Request $request) : bool
 {
     $oldPassword = $request->request->get('oldPassword');
     $newPassword = $request->request->get('newPassword');
     /** @var UserVO $user */
     $user = $request->attributes->get('user');
     if (!$this->passwordHasher->verifyHash($oldPassword, $user->getPassword())) {
         throw new UserException('Invalid Password given');
     }
     $this->user->changePassword($user, $newPassword);
     return true;
 }
Beispiel #3
0
 /**
  * @param string $password
  * @param string $hash
  * @return bool
  */
 public function verifyHash(string $password, string $hash) : bool
 {
     return $this->hasher->verifyHash($password, $hash);
 }