public function loginAction() { $form = new LoginForm(); $form->get('submit')->setValue('Login'); $request = $this->getRequest(); if ($request->isPost()) { $account = new Account(); $form->setInputFilter($account->getLoginInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $account->exchangeArray($form->getData()); $result = $this->authenticate($account); switch ($result) { case AUTH_RESULT::NOT_FOUND: return ['form' => $form, 'errors' => $errors = ['name' => 'name_not_available']]; case AUTH_RESULT::WRONG_CREDENTIALS: return ['form' => $form, 'errors' => $errors = ['password' => 'wrong_password']]; case AUTH_RESULT::NOT_CONFIRMED: return ['form' => $form, 'errors' => $errors = ['name' => 'not_confirmed']]; case AUTH_RESULT::SUCCESS: $account = $this->getAccountTable()->getAccountBy(['name' => $account->getName()]); SessionService::createUserSession($account); return $this->redirect()->toRoute('account', ['action' => 'profile']); } } else { $errors = $form->getMessages(); return ['form' => $form, 'errors' => $errors]; } } return ['form' => $form]; }
public function addAction() { $form = new AccountForm(); $form->get('submit')->setValue('Add'); $element = new Element\Text('my-text'); $element->setLabel('Please note your account #')->setLabelAttributes(array('class' => 'note-label')); $request = $this->getRequest(); if ($request->isPost()) { $account = new Account(); $form->setInputFilter($account->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $account->exchangeArray($form->getData()); $account->movie_id_1 = ''; $account->movie_id_2 = ''; $account->movie_id_3 = ''; $this->getAccountTable()->saveAccount($account); // Redirect to list of Accounts return $this->redirect()->toRoute('movie', array('id' => $account->id)); } } return array('form' => $form, 'element' => $element); }
public function setRolesAction() { if (!PermissionChecker::check(Role::CO)) { return $this->redirect()->toRoute('account', ['action' => 'noright']); } $form = new SearchUserForm(); $request = $this->getRequest(); $paginator = $this->getAccountTable()->getUsersAndAbove(true); $page = (int) $this->params()->fromQuery('page', 1); $name = $this->params()->fromQuery('name', ''); $role = $this->params()->fromQuery('role', ''); $account = new Account(); $form->setInputFilter($account->getUserSearchInputFilter()); $form->setData(['name' => $name, 'role' => $role]); if ($form->isValid()) { $account->exchangeArray($form->getData()); $paginator = $this->getAccountTable()->getUsersAndAbove(true, $name, $role); } $role_strings = Role::getAllRoles(); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage(25); return ['form' => $form, 'users' => $paginator, 'role_strings' => $role_strings]; }
public function lostpasswordAction() { $form = new LostPasswordForm(); $request = $this->getRequest(); if ($request->isPost()) { $account = new Account(); $form->setInputFilter($account->getLostPasswordInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $account->exchangeArray($form->getData()); $account = $this->getAccountTable()->getAccountBy(['email' => $account->getEmail()]); if (!$account) { return $this->redirect()->toRoute('account', ['action' => 'nouser']); } $account->setUserHash(hash('sha256', $account->getName())); $this->getAccountTable()->saveAccount($account); $this->sendLostPasswordMail($account); return $this->redirect()->toRoute('account', ['action' => 'lostpasswordsuccess']); } return ['form' => $form, 'errors' => 'No valid E-Mail adress']; } return ['form' => $form]; }