public function onSuccess()
 {
     $v = $this->values;
     $user = $this->orm->users->getByEmail($v->email);
     if ($user && $user->registered) {
         $this->addError('duplicate');
         return;
     }
     if (!$user) {
         $user = new User();
         $user->email = $v->email;
         $this->orm->users->attach($user);
     }
     $user->gender = $v->gender;
     $user->setNames($v->name);
     $user->registered = TRUE;
     $plainHash = Passwords::hash($v->password);
     $user->password = $this->aes->encrypt($plainHash);
     $this->orm->flush();
     /** @var Auth $presenter */
     $presenter = $this->presenter;
     $presenter->user->login(new Identity($user->id));
     $this->iLog('auth.registration.password', ['entropy' => $this->entropy->compute($v->password, $user)]);
     $presenter->onLogin($user, TRUE);
 }
 /**
  * @deprecated
  * @param string $password
  * @param $user
  * @throws AuthenticationException
  */
 private function authOldPassword($password, $user)
 {
     list($_, $hash, $salt) = explode(';', $user->password);
     if ($this->calculateHash($password, $salt) !== $hash) {
         throw new AuthenticationException('auth.flash.wrongPassword', self::INVALID_CREDENTIAL);
     }
     $plainHash = Passwords::hash($password);
     $user->password = $this->aes->encrypt($plainHash);
     $this->orm->flush();
 }
 public function onSuccess()
 {
     $v = $this->values;
     /** @var Auth $presenter */
     $presenter = $this->presenter;
     $user = $presenter->userEntity;
     $plainHash = Passwords::hash($v->password);
     $user->password = $this->aes->encrypt($plainHash);
     $this->orm->flush();
     $this->iLog('form.changePassword', ['entropy' => $this->entropy->compute($v->password, $user)]);
     $presenter->flashSuccess('auth.changePassword.success');
     $presenter->redirect('Profile:');
 }
Example #4
0
 public function actionGoogleResponse()
 {
     try {
         $me = $this->google->getProfile();
         $this->registerOrLogin($me, function ($id) {
             return $this->orm->users->getByGoogleId($id);
         }, function (User $user, $me) {
             $user->googleId = $me->id;
             $token = $this->google->getAccessToken()['access_token'];
             $user->googleAccessToken = $this->aes->encrypt($token);
         }, 'google');
     } catch (Google_Exception $e) {
         $this->log->addAlert('Google login request failed', ['error' => $e->getMessage()]);
         $this->flashError('auth.flash.google.error');
     }
     $this->redirect('Auth:in');
 }