예제 #1
0
 /**
  * Dispatch is called before the action, using this to make sure any request to the app without an authenticated
  * user is directed to the signin,
  *
  * @param Request $request
  * @param Response $response
  * @return mixed|\Zend\Http\Response|Response
  */
 public function dispatch(Request $request, Response $response = null)
 {
     $this->user = ParseUser::getCurrentUser();
     if (!$this->user or !isset($_SESSION['todo']['user']) or $this->user->getUsername() !== $_SESSION['todo']['user']) {
         return $this->redirect()->toRoute('auth', ['action' => 'signin']);
     }
     return parent::dispatch($request, $response);
     // TODO: Change the autogenerated stub
 }
예제 #2
0
 public function testUserAttributes()
 {
     $user = new ParseUser();
     $user->setUsername('asdf');
     $user->setPassword('zxcv');
     $user->setEmail('*****@*****.**');
     $this->assertEquals('asdf', $user->getUsername());
     $this->assertEquals('*****@*****.**', $user->getEmail());
 }
예제 #3
0
 /**
  * Expects a post with email / password (or the form is just shown). Creates a new user (if possible) then redirects
  * to the app controller on success, or itself (PRG) with a flash message on error.
  */
 public function signupAction()
 {
     if (!$this->request instanceof Request or !$this->request->isPost()) {
         return;
         //nothing to do
     }
     $email = $this->request->getPost('email');
     $password = $this->request->getPost('password');
     $user = new ParseUser();
     $user->setUsername($email);
     $user->setPassword($password);
     try {
         $user->signUp();
         $_SESSION['todo']['user'] = $user->getUsername();
         $this->redirect()->toRoute('app');
     } catch (ParseException $e) {
         $this->flashMessenger()->addErrorMessage($e->getMessage());
         $this->redirect()->toRoute('auth', ['action' => 'signup']);
     }
 }