Skip to content

Instantly share code, notes, and snippets.

@harikt
Created June 24, 2014 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/2c82ae6f316615b431f5 to your computer and use it in GitHub Desktop.
Save harikt/2c82ae6f316615b431f5 to your computer and use it in GitHub Desktop.
User bundle login action. Where will the redirect goes in ADR .
<?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