Created
December 16, 2013 03:40
-
-
Save sobanvuex/7981958 to your computer and use it in GitHub Desktop.
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 | |
// auth.php | |
use lithium\security\Auth; | |
Auth::config([ | |
'auth' => [ | |
'adapter' => 'Form', | |
'fields' => [ | |
// this configuration does not work | |
'email', | |
'password', | |
// neither is this | |
'user[email]' => 'email', | |
'user[password]' => 'password', | |
// neither is this one | |
'user.email' => 'email', | |
'user.password' => 'password', | |
], | |
'scope' => [ | |
'active' => 1 | |
] | |
] | |
]); | |
// MyController.php | |
class MyController extends \lithium\action\Controller { | |
public function login() { | |
if ($this->request->data) { | |
return Auth::check('auth', $this->request) ? | |
$this->redirect('Index::index') : | |
['error' => 'Invalid login']; | |
} else if (Auth::check('auth')) { | |
return $this->redirect('Index::index'); | |
} | |
} | |
} | |
// login.html.php | |
<?= $this->form->create(compact('user'), ['role' => 'form']); ?> | |
<?= $this->form->field('user.email', [ | |
'type' => 'email', | |
'template' => '{:input}', | |
'class' => 'form-control', | |
'placeholder' => 'you@example.com', | |
'required' => 'required', | |
'autofocus' => 'autofocus' | |
]); ?> | |
<?= $this->form->password('user.password', [ | |
'class' => 'form-control', | |
'required' => 'required' | |
]); ?> | |
<?= $this->form->submit('Login', ['class' => 'btn btn-primary btn-lg btn-block']); ?> | |
<?= $this->form->end(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment