Пример #1
0
 public function __invoke()
 {
     $user = $this->userRepository->authenticate($this->username, $this->password);
     if (false !== $user) {
         $this->session->set(LoginContext::LOGIN_VAR, $user->id());
         $this->redir->redirect(303, '/games');
         return;
     }
     $this->view->display('home.html', ['msg' => 'Invalid login']);
 }
Пример #2
0
 /**
  * Returns the user who is logged in, or null if no user is logged in
  * @return User|null
  */
 public function currentUser()
 {
     if (is_null($this->user)) {
         $userId = $this->session->get(static::LOGIN_VAR, null);
         if (null === $userId) {
             return null;
         }
         assert(is_int($userId) && $userId > 0, "Since we're relying on other code to set this, we need to be sure it's correct (a positive integer)");
         $user = $this->userRepository->find($userId);
         if (!$user) {
             assert(false, "We should never have a session existing with a user id that isn't actually in the database...");
             return null;
         }
         $this->user = $user;
     }
     return $this->user;
 }
Пример #3
0
 public function __invoke()
 {
     // validation goes here
     $this->userRepository->newUserUnsafe($this->dispname, $this->username, $this->password, $this->phone);
     $this->redirector->redirect(303, '/');
 }