diff --git a/src/Events/Listeners/AuthenticationListener.php b/src/Events/Listeners/AuthenticationListener.php index 2a65ad7..2a66c6a 100644 --- a/src/Events/Listeners/AuthenticationListener.php +++ b/src/Events/Listeners/AuthenticationListener.php @@ -30,6 +30,14 @@ public function beforeDispatchLoop(Event $event, DispatcherInterface $dispatcher ); } + // TODO: Verify if user can login or passwords exceeded + //$this->getDI()->getShared('eventsManager')->attach( + // 'auth:beforeLogin', + // function (Event $event, AuthManager $manager, $data) { + // return true; + // } + // ); + return !$event->isStopped(); } diff --git a/src/Form/LoginForm.php b/src/Form/LoginForm.php new file mode 100644 index 0000000..5c558c1 --- /dev/null +++ b/src/Form/LoginForm.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phlexus\Modules\BaseAdmin\Form; + +use Phlexus\Form\FormBase; +use Phalcon\Forms\Element\Email; +use Phalcon\Forms\Element\Password; +use Phalcon\Validation\Validator\PresenceOf; + +class LoginForm extends FormBase +{ + /** + * Initialize form + */ + public function initialize() + { + parent::initialize(); + + $email = new Email('email', [ + 'required' => true, + 'class' => 'form-control', + 'placeholder' => 'Email' + ]); + + $email->addValidator(new PresenceOf(['message' => 'Email is required'])); + + $this->add($email); + + $password = new Password('password', [ + 'required' => true, + 'class' => 'form-control', + 'placeholder' => 'Password' + ]); + + $password->addValidator(new PresenceOf(['message' => 'Password is required'])); + + $this->add($password); + } +}