コード例 #1
0
 public function executeAction()
 {
     if ($this->route->isAuthRequired() && !Authentication::isAuthenticated()) {
         $loginRoute = Route::findRoute(\Config\App\LOGIN_PAGE_ROUTE, Route::METHOD_GET);
         $obj = ControllerHandler::instance()->redirectToRoute($loginRoute, $this->request);
         $action = $loginRoute->getAction();
         $parameters = Route::getRouteParameters($this->route, $this->request);
         return call_user_method_array($action, $obj, $parameters);
     }
     $action = $this->route->getAction();
     $parameters = Route::getRouteParameters($this->route, $this->request);
     return call_user_method_array($action, $this, $parameters);
 }
コード例 #2
0
 public function processRegistration()
 {
     $errors = [];
     $user = new User();
     $user->setUsername($this->request->getPost()['username']);
     $user->setPassword($this->request->getPost()['password']);
     if (!$user->get(['username' => $user->getUsername()])->IsEmpty()) {
         $errors[] = "Benutzername existiert bereits!";
     }
     if ($user->getPassword() !== $this->request->getPost()['password_confirm']) {
         $errors[] = "Die eingegebenen Passwörter stimmen nicht überein!";
     }
     if (count($errors) === 0) {
         $user->save();
         Authentication::authenticate($user);
         return $this->redirectAction("~/Login");
     }
     $this->viewData['errors'] = $errors;
     return $this->view("Register");
 }