Beispiel #1
0
 function create()
 {
     $request = $this->app->request;
     $username = $request->post('user');
     $pass = $request->post('pass');
     $hashed = Hash::make($pass);
     $user = User::makeEmpty();
     $user->setUsername($username);
     $user->setHash($hashed);
     $validationErrors = User::validate($user);
     if (sizeof($validationErrors) > 0) {
         $errors = join("<br>\n", $validationErrors);
         $this->app->flashNow('error', $errors);
         $this->render('newUserForm.twig', ['username' => $username]);
     } else {
         $user->save();
         $this->app->flash('info', 'Thanks for creating a user. Now log in.');
         $this->app->redirect('/login');
     }
 }