loginRedirectとadminのRouting
管理側と一般ユーザで認証テーブルを分ける試みをしてましたが、ACLを使ってアクセス制限かける方法に変えることにしました。
その準備で、UsersとMembersを統合、DB定義も見直し。
ログイン画面はXOOPSに倣い、一般ユーザ側ログインで一本化してadminに持たせない。
として、users/loginを設けてloginRedirectに指定したら、admin側の遷移がおかしくなりました。
loginRedirectの指定
function beforeFilter() { parent::beforeFilter(); (中略) // ログイン後遷移先 $this->AuthPlus->loginRedirect = 'users/index'; }
として、例えば
function admin_change_password($id = null) { (中略) if ($this->User->save($this->data)) { $this->Session->setFlash(__('The password has been changed.', true)); $this->redirect(array('action'=>'index'));
とすると、cakephp_root/admin/index に遷移、コントローラー指定不備でエラーになります。
かといって、loginRedirectを指定しないと、cakephp_root/users/loginをURL指定して表示、ログインした場合、ログインしたにもかかわらずログイン画面が再表示されてしまいます・・・
admin側では、redirect先をコントローラまで明示して指定することで解消しました。
function admin_change_password($id = null) { (中略) if ($this->User->save($this->data)) { $this->Session->setFlash(__('The password has been changed.', true)); $this->redirect(array('controller' => 'users', 'action'=>'index'));