0
我的客戶有特定的要求,爲應用程序添加「超級登錄」的可能性,這將使他能夠以任何用戶身份通過超級密碼登錄。我這樣想:在CakePHP Auth過程的某個地方添加一個條件,可以使用特殊的字符串作爲密碼,所以這個字符串用戶將通過$ this-> Auth-> login()方法進行身份驗證,通過正常登錄使用用戶密碼的方式。 有沒有人以前做過?有沒有辦法如何獲得這個目標?如何添加超級密碼到CakePHP 2.0身份驗證
這裏是UserController中,它執行身份驗證的用戶我的代碼行:
public function admin_login() {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
}
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->Session->setFlash(__('Successfully Logged In'),'flash_custom_success');
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'),'flash_custom_error');
}
}
}
難道沒有辦法讓你的客戶相信這是不安全的嗎?任何人與SuperPassword(配樂需要)將造成嚴重破壞...特別是如果他想要和「簡單」的密碼記住,並以「superPassword123」結束 – Nunser 2014-09-24 15:16:08
我同意,可能更好的方法,將是添加管理員切換到另一個用戶。後臺邏輯只會在Session中重寫$ user數組,這應該會達到想要的效果。 – 2014-09-24 15:52:22