function create() { try { $user = User::create($this->getRequest()->request); UserSession::getInstance()->signInWithUser($user); $this->respondTo('html', function () use($user) { $data['user'] = $user; $this->render(new View\TwigView('user/registered.html', $data)); }); } catch (ValidationException $e) { $this->respondTo('html', function () use($e) { $this->getResponse()->redirect('App\\Auth\\Controllers\\SessionController', 'signIn'); }); } }
/** * @return User|null if user is a guest, null is returned */ public function getUser() { return $this->isSignedIn() ? User::find($this->userId) : null; }