01.30 php saved
Baz
Tags add more
AuthComponent Broken  
Note
AuthComponent issues
login and logout can't be part of the allowed list.
  1. // ==========================================================
  2. // ==========================================================
  3. // ==========================================================
  4. // ==========================================================
  5. class AppController extends Controller {
  6.  
  7.     var $helpers = array('Html', 'Form', 'Javascript');
  8.     var $components = array('Auth');
  9.  
  10.     function beforeFilter() {
  11.         //debug($this->Auth);
  12.         //debug($this->Session);
  13.         if (@$this->params['prefix'] == "admin") {
  14.             $this->layout = "admin";
  15.             $this->set("prefix", "admin_");
  16.         } else {
  17.             $this->set("prefix", "");
  18.         }
  19.  
  20.         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
  21.         $this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display', 'home');
  22.         $this->Auth->allow(
  23.             'display',
  24.             'index',
  25.             'view',
  26.             'login',
  27.             'logout',
  28.             'latest');
  29.         $this->Auth->authorize = 'controller';
  30.     }
  31.  
  32. }
  33.  
  34. // ==========================================================
  35. // ==========================================================
  36. // ==========================================================
  37. // ==========================================================
  38. class UsersController extends AppController {
  39.  
  40.     var $name = 'Users';
  41.     var $helpers = array('Html', 'Form', 'Session');
  42.     var $components = array('Auth');
  43.  
  44.     function login() {
  45.     }
  46.  
  47.     function logout() {
  48.         $this->Session->setFlash("Logged out");
  49.         $this->redirect($this->Auth->logout());
  50.     }
  51.  
  52.     // .... snip standard baked junk
  53. }
  54.  
  55. // ==========================================================
  56. // ==========================================================
  57. // ==========================================================
  58. // ==========================================================
  59. class User extends AppModel {
  60.  
  61.     var $name = 'User';
  62.     var $useTable = 'users';
  63.  
  64. }
  65.  
  66. // ==========================================================
  67. // ==========================================================
  68. // ==========================================================
  69. // ==========================================================
  70. // LOGIN.CTP EXTACT
  71. <?php echo $form->create('User', array('action' => 'login', 'name' => 'loginForm')); ?>
  72.     <table class="formTable">
  73.         <tr>
  74.             <th>username</th>
  75.             <td><?php echo $form->input('username'); ?></td>
  76.         </tr>
  77.         <tr>
  78.             <th>password</th>
  79.             <td><?php echo $form->input('password', array('value' => null)); ?></td>
  80.         </tr>
  81.         <tr>
  82.             <td/>
  83.             <td>
  84.                 <a href="#" onClick="javascript:document.loginForm.submit();">< login</a>
  85.             </td>
  86.         </tr>
  87.     </table>
  88. <?php echo $form->end(); ?>
  89.  
Parsed in 0.128 seconds, using GeSHi 1.0.7.14

Modify this Paste