Logging in
Our application is now under access control, and any attempt to view non-public pages will redirect you to the login page. However, we will need to create a login view before anyone can login. Add the following to app/views/users/login.ctp if you haven't done so already.
<h2>Login</h2><?phpecho $form->create('User', array('url' => array('controller' => 'users', 'action' =>'login')));echo $form->input('User.username');echo $form->input('User.password');echo $form->end('Login');?>
You may also want to add a flash() for Auth messages to your layout. Copy the default core layout - found at cake/libs/views/layouts/default.ctp - to your app layouts folder if you haven't done so already. In app/views/layouts/default.ctp add
$session->flash('auth');
You should now be able to login and everything should work auto-magically. When access is denied Auth messages will be displayed if you added the $session->flash('auth')


Коментарии:
Добавить коментарий