2017-09-26 44 views
0

如何使蛋糕中的Auth Component重定向到登錄頁面並且不保留以前的路線。例如,如果我要將Auth組件重定向到/users/login而不是/users/login?redirect=%2index謝謝。登錄前請不要忘記之前的路線Cakephp 3

+0

遵循這樣的: https://stackoverflow.com/a/44263171/3278639 – Mustafa

回答

0

也許你應該考慮到不是考慮到前一頁並強制重定向到你選擇的特定控制器的動作。

<?php 
public function login() 
{ 
    if ($this->request->is('post')) { 
     $user = $this->Auth->identify(); 
     if ($user) { 
      $this->Auth->setUser($user); 
      return $this->redirect(['controller' => 'YourController', 'action' => 'YourAction']); 
     } 
     $this->Flash->error(__('Invalid credentials.')); 
    } 
} 
?> 
+0

是啊,我這樣做,但沒有作品。他仍然重定向到之前的路線。 – ArAlM