Die before_Filter() Methode in meinem app_controller sieht jetzt so aus:
- Code: Alles auswählen
function beforeFilter
() { // [mp:start] $this->Auth->loginAction = array(Configure
::read('Routing.admin') => true, 'controller' => 'users', 'action' => 'login'); $this->Auth->autoRedirect = false; // [mp:end] header('Content-type: text/html; charset="utf-8"'); uses
('L10n'); setlocale(LC_ALL
, 'de_DE.utf8'); Configure
::write('Config.language', "de"); // [mp:start] $this->Auth->authorize = 'controller'; // [mp:end] //backend is protected if(!empty($this->params['admin']) &
;&
; $this->params['admin'] == 1){ $this->layout = "admin"; if (isset($this->Auth)) { $this->Auth->userModel = 'User'; $this->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Auth->loginAction = '/admin/users/login'; $this->Auth->loginRedirect = '/admin/users/'; $this->Auth->autoRedirect = true; $this->user = $this->Auth->user(); if(empty($this->user) &
;&
; $this->RequestHandler->isAjax()){ $this->render(null, 'ajax', APP
. 'views/elements/ajax_login_message.ctp'); } $this->set('user', $this->user); $this->_setAdminMenu
(); } if($this->name == 'Users' &
;&
; $this->action == 'admin_login'){ $this->layout = 'admin_login'; } }else{ $this->Auth->allow(); } }
Von mir sind nur die markierten Stellen. Leider wird die Loginseite nicht aufgerufen, wenn ich nur
http://www.domain.de aufrufe. Stattdessen sehe ich diese CakePHP Standardseite mit den grünen Boxen ("Sweet, "App" got Baked by CakePHP!"). Die Route habe ich erstmal wieder auskommentiert.
Edit: Wenn ich den Teil mit
//backend is protected auskommentiere, komme ich zur Loginseite, allerdings kann ich mich dann nicht anmelden, weil er meint Benutzername und/oder Passwort wären falsch. OK, die Authentifizierung findet irgendwo in diesem Codeblock statt. Allerdings verstehe ich noch nicht so ganz wie das funktioniert.