function create() { try { $params = $this->getRequest()->request; $email = $params->get('user[email]', null, true); $password = $params->get('user[password]', null, true); UserSession::signIn($email, $password); $this->respondTo('html', function () { $this->getResponse()->redirect('App\\Store\\Controllers\\ProductController', 'index'); }); } catch (ValidationException $e) { // Validation failed $this->respondTo('html', function () { $this->getResponse()->redirect('App\\Auth\\Controllers\\SessionController', 'signIn'); }); } catch (ResourceNotFoundException $e) { // User not found $this->respondTo('html', function () { $this->getResponse()->redirect('App\\Auth\\Controllers\\SessionController', 'signIn'); }); } catch (AuthenticationFailedException $e) { // User authentication failed $this->respondTo('html', function () { $this->getResponse()->redirect('App\\Auth\\Controllers\\SessionController', 'signIn'); }); } }