function beforeFilter() { $hasAdmin = $this->User->hasAdminUser(); $this->set('has_admin', $hasAdmin); // RSS Authentication by user model if ($this->RequestHandler->isRss()) { $this->Auth->allow('index'); $this->Security->loginOptions = array('type' => 'basic', 'login' => 'authenticate', 'realm' => 'My_RSS_Feeds'); $this->Security->loginUsers = array(); $this->Security->requireLogin('*'); } // UsersControllerの認証除外設定 if (get_class($this) == "UsersController") { if (!$hasAdmin) { $this->Auth->allow(array('add')); } $this->Auth->allow(array('reset_password', 'reset_password_mail')); } if (isset($this->Auth)) { //コントローラー側でさらに詳細を判別 $this->Auth->authorize = 'controller'; //ログインできるユーザの条件をデータベースのフィールドの値で指定 $this->Auth->userScope = array("User.disabled" => 0); //ログイン処理を行うactionを指定(/users/loginがデフォルト)。 $this->Auth->loginAction = "/users/login"; //ログインが失敗した際のエラーメッセージ $this->Auth->loginError = __("Invalid username or password", true); //権限が無いactionを実行した際のエラーメッセージ $this->Auth->authError = __('You have no privileges', true); //ログイン後にリダイレクトするURL $this->Auth->loginRedirect = "/users/index"; //ユーザIDとパスワードがあるmodelを指定(’User’がデフォルト) $this->Auth->userModel = "User"; //ユーザIDとパスワードのフィールドを指定(username、password がデフォルト) $this->Auth->fields = array("username" => "loginname", "password" => "password"); //自動リダイレクトしない $this->Auth->autoRedirect = false; // ログインユーザ情報をviewに受け渡し $login_user = $this->Auth->User(); $this->set('login_user', $login_user['User']); } $project = $this->Project->getProjectInfo(); $this->set('project_info', $project["Project"]); $sprint = $this->Sprint->getActiveSprintList(); $this->set('sprint_info', $sprint); }