Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth and forms #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Events/Listeners/AuthenticationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
50 changes: 50 additions & 0 deletions src/Form/LoginForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* This file is part of the Phlexus CMS.
*
* (c) Phlexus CMS <[email protected]>
*
* 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);
}
}