/**
  * Creates a User
  */
 public function createAction()
 {
     if ($this->request->isPost()) {
         $user = new Users();
         $user->assign(array('name' => $this->request->getPost('name', 'striptags'), 'email' => $this->request->getPost('email', 'email')));
         if (!$user->save()) {
             $this->flash->error($user->getMessages());
         } else {
             $this->flash->success("User was created successfully");
             Tag::resetInput();
         }
     }
     $this->view->form = new UsersForm(null);
 }
 /**
  * Allow a user to signup to the system
  */
 public function signupAction()
 {
     $form = new SignUpForm();
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) != false) {
             $user = new Users();
             $user->assign(array('name' => $this->request->getPost('name', 'striptags'), 'email' => $this->request->getPost('email'), 'password' => $this->security->hash($this->request->getPost('password'))));
             if ($user->save()) {
                 return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             }
             $this->flash->error($user->getMessages());
         }
     }
     $this->view->form = $form;
 }
Beispiel #3
0
 /**
  * Get the entity related to user in the active identity
  *
  * @return \MotorBike\Models\Users
  */
 public function getUser()
 {
     $identity = $this->session->get('auth-identity');
     if (isset($identity['id'])) {
         $user = Users::findFirstById($identity['id']);
         if ($user == false) {
             throw new Exception('The user does not exist');
         }
         return $user;
     }
     return false;
 }