public function initialize() { $email = new \Phalcon\Forms\Element\Email('email', array('placeholder' => '*****@*****.**')); $email->setLabel('Enter Your E-Mail:'); $email->addValidator(new \Phalcon\Validation\Validator\Email(array('message' => 'The E-Mail is not valid.'))); $this->add($email); $password = new \Phalcon\Forms\Element\Password('password', array('placeholder' => 'Your password')); $password->setLabel('Password:'******'message' => 'The Password is required.'))); $this->add($password); }
public function loginAction() { $form = new \Phalcon\Forms\Form(); $form->add($user = new \Phalcon\Forms\Element\Email('user')); $form->add($pass = new \Phalcon\Forms\Element\Password('password')); $form->add($twoFactorAuth = new \Phalcon\Forms\Element\Numeric('token')); $user->addValidator(new PresenceOf(['message' => 'Username is required.'])); $pass->addValidator(new PresenceOf(['message' => 'Password is required.'])); $twoFactorAuth->addValidator(new PresenceOf(['message' => 'Token is required.'])); $this->view->setVar('form', $form); if ($this->request->isPost() && $form->isValid($this->request->getPost())) { if (!$this->security->checkToken()) { $this->flash->error('The form security token was invalid. Please submit the form again.'); $this->cleanUpRequest(); return false; } $this->tryLogin($this->request->getPost()); } $this->cleanUpRequest(); }