[英]How to add Super Password to CakePHP 2.0 Authentication
我的客戶有一個特定的請求,要求在應用程序中添加“超級登錄”的可能性,這要歸功於他的“超級密碼”,使他能夠以任何用戶身份登錄。 我是這樣想的:在CakePHP Auth過程中的某個地方添加了一個條件,該條件將允許使用特殊字符串作為密碼,因此,使用該字符串用戶,我們將通過$ this-> Auth-> login()方法對他進行身份驗證,該用戶通常可以登錄用戶密碼的方式。 有人做過嗎? 有什么辦法可以實現這個目標?
這是我在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');
}
}
}
經過考慮(而不是喜歡“超級密碼”的想法),我決定為管理員創建用戶切換功能。 該解決方案被客戶接受。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.