I'm trying to design the login process in a particular way, but am
having trouble using the Auth component and would really appreciate
some assistance.
First of all, this is my app_controller.php file:
<?php
class AppController extends Controller {
var $components = array( 'Auth', 'Session' );
}
?>
These are the functions in users_controller:
function beforeFilter() {
$this->Auth->fields = array(
'username' => 'email',
'password' => 'password' );
$this->Auth->allow( '*' );
$this->Auth->loginRedirect = array( 'controller' => 'pages',
'action' => 'home' );
parent::beforeFilter();
}
function login() {
}
function logout() {
$this->redirect( $this->Auth->logout() );
}
Finally, this is my login.ctp file in app/views/users/
<?php
echo $session->flash( 'auth' );
echo $form->create( 'User', array( 'action' => 'login' ) );
echo $form->input( 'email', array( 'type' => 'text' ) );
echo $form->input( 'password' );
echo $form->end( 'Login' );
?>
This is all taken pretty much from book.cakephp.org. The first trouble
I'm having is that I can't get out of the login page mydomain.com/
users/login. Login seems to be successful because when I try an
incorrect password I get the login failed message. With the correct
password, however, I'm just taken back to the login action. If I try
to go to another action, even just the home page, I'm redirected to
the login action again. When I login I see pages/home flash briefly,
but then it returns to users/login. All of the links on the default
page (such as /pages/about_us, etc.) just keep me at users/login.
Isn't the line that says $this->Auth->allow( '*' ) going to allow me
to see any page when I'm not logged in and if I am logged in shouldn't
it allow me to go elsewhere in the system?
Please help me understand what I'm doing incorrectly.
Thanks,
Chuck
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en