我想寫一個條件來檢查特定參數和用戶憑證。如果用戶沒有兩個憑證之一併傳遞正確的參數,他們將被轉發到安全的登錄屏幕。如何在symfony 1.4中使用sfGuard插件編寫條件if for user privilege
這就是我所做的有工作:
if ($request->getParameter('profile_type') == 'foo' && !$this->getUser()->isAdmin()) {
return $this->redirect('sfGuardAuth/secure');
}
但我添加了一個新的用戶羣,所以我需要的是這樣的:
if ($request->getParameter('profile_type') == 'foo' && (!$this->getUser()->isAdmin() || !$this->getUser()->isFaculty()) {
return $this->redirect('sfGuardAuth/secure');
}
所以,如果你不是管理員或教師,你會得到重定向。
這是一個語法或邏輯問題?
UPDATE
這是工作,但它似乎是錯誤的邏輯
if (($request->getParameter('profile_type') == 'foo') && (!$this->getUser()->isAdmin() && !$this->getUser()->isFaculty())) {
return $this->redirect('sfGuardAuth/secure');
}
這不是說,如果用戶不是管理員或IS師資?它應該是用戶不是管理員或非教職員工。我給了它一個旋轉,它適用於管理員而不是教職員工。看到編輯過的帖子,看看有什麼工作,雖然這對我沒有意義。 –