User bundle login action. Where will the redirect goes in ADR .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Hari\User_Bundle\Action; | |
| use Aura\Web\Request; | |
| use Hari\User_Bundle\Input\LoginForm; | |
| use Hari\User_Bundle\Responder\LoginResponder; | |
| use Aura\Auth\Adapter\AbstractInterface as AuthAdapter; | |
| use Aura\Auth\User; | |
| class LoginAction extends AbstractUserAction | |
| { | |
| /** | |
| * | |
| * @param Request $request | |
| * @param LoginResponder $responder | |
| * @param LoginForm $form | |
| * @param User $user | |
| * @param Authadapter $auth_adapter | |
| */ | |
| public function __construct( | |
| Request $request, | |
| LoginResponder $responder, | |
| LoginForm $form, | |
| User $user, | |
| AuthAdapter $auth_adapter | |
| ) { | |
| $this->request = $request; | |
| $this->responder = $responder; | |
| $this->form = $form; | |
| $this->user = $user; | |
| $this->auth_adapter = $auth_adapter; | |
| } | |
| public function __invoke() | |
| { | |
| if ($this->user->isValid()) { | |
| // redirect | |
| } | |
| if ($this->request->method->isPost()) { | |
| $cred = array( | |
| 'username' => $this->request->post->get('username'), | |
| 'password' => $this->request->post->get('password') | |
| ); | |
| $this->form->fill($cred); | |
| if ($this->form->filter()) { | |
| $this->auth_adapter->login($this->user, $cred); | |
| } | |
| } | |
| return $this->response(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment