Exemplo n.º 1
0
 /**
  * @return User|null null if not logged in
  */
 public function getUser()
 {
     if ($this->isLoggedIn() && !$this->user) {
         $this->user = $this->userRepository->getByUsername($this->getSession());
     }
     return $this->user;
 }
Exemplo n.º 2
0
 /**
  * @return RegisterView
  */
 public function register()
 {
     if ($this->registerView->haveRegistered()) {
         $user = $this->registerView->getUser();
         if ($user->isValid()) {
             try {
                 $this->userRepository->create($user);
                 $this->auth->login($user);
                 $token = new Token($this->auth->getUser());
                 $this->tokenRepository->insert($token);
                 $this->credentialsHandler->saveSecret($token);
                 $this->router->redirectTo(Router::INDEX);
             } catch (\DomainException $e) {
                 $this->registerView->addUsernameExistsError();
             }
         }
     }
     return $this->registerView;
 }