我開始瀏覽cakephp教程,我完全按照教程中所示覆制源代碼。Cakephp簡單身份驗證教程頁面不會重定向到當前頁面
我已經完成了博客教程,並且一切看起來都不錯,現在我進入了「簡單身份驗證和授權應用程序」(http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html)教程,但遇到了這個問題。
添加頁面加載罰款:
「... /應用/ Webroot公司/ index.php文件/用戶/添加」
點擊提交後,它重定向我到這個網址(與額外的「用戶」字符串)和錯誤消息。
「... /應用/ Webroot公司/ index.php文件/用戶/用戶/添加」
Missing Method in UsersController Error: The action Users is not defined in controller UsersController Error: Create UsersController::Users() in file: app/Controller/UsersController.php. class UsersController extends AppController { public function Users() { } }
讓我知道我應該開始檢查,謝謝。
AppController的
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authorize' => array('Controller') // Added this line
)
);
public function beforeFilter() {
$this->Auth->allow('index', 'view');
}
public function isAuthorized($user) {
// Admin can access every action
if (isset($user['role']) && $user['role'] === 'admin') {
return true;
}
// Default deny
return false;
}
}
'/ app/webroot/index.php/Users/add'? 它可能是一個URL重寫問題:你是否遵循了URL重寫教程:http://book.cakephp.org/2.0/en/installation/url-rewriting.html – ptica 2013-03-18 19:04:39
只是做了同樣的事情。 – MCHam 2013-03-19 15:02:11