本文整理汇总了PHP中AuthComponent::User方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthComponent::User方法的具体用法?PHP AuthComponent::User怎么用?PHP AuthComponent::User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthComponent
的用法示例。
在下文中一共展示了AuthComponent::User方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAuthorized
public function isAuthorized($user)
{
if (in_array(strtolower($this->action), array('add', 'edit', 'delete', 'index', 'adminlinks'))) {
return AuthComponent::User('role') == '3' ? true : false;
}
return true;
}
示例2: beforeFilter
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);
}
示例3: _getCurrentUserId
protected function _getCurrentUserId()
{
if (isset($this->Auth)) {
$user_id = $this->Auth->User("id");
} else {
$user_id = AuthComponent::User("id");
}
return $user_id;
}
示例4: isSubscribed
public function isSubscribed($subscribedUsers)
{
foreach ($subscribedUsers as $user) {
if ($user['User']['id'] == AuthComponent::User('id')) {
return $user['Notification']['token'];
}
}
return null;
}
示例5: isAuthorized
public function isAuthorized($user)
{
parent::isAuthorized($user);
if ($this->request->action === 'add') {
return $this->Thread->SubForum->canPostHere($this->request->params['id']);
}
if ($this->request->action === 'sticky' || $this->request->action === 'lock' || $this->request->action === 'setHome') {
return AuthComponent::User('role') == '3';
}
if ($this->request->action === 'edit') {
$articleId = $this->request->params['id'];
return $this->Thread->isOwnedBy($articleId);
}
return true;
}
示例6: displayTopics
public function displayTopics($sub_forum_id = null, $slug = null)
{
$this->SubForum->id = $sub_forum_id;
if (!$this->SubForum->exists()) {
throw new NotFoundException('Sub forum not found');
}
$this->paginate = array('conditions' => array('Thread.sub_forum_id' => $sub_forum_id, 'Thread.thread_id' => '0'), 'order' => array('Thread.sticky' => 'DESC', 'Thread.latest_reply_thread_id' => 'DESC'), 'limit' => 15);
$this->SubForum->recursive = -1;
$subForum = $this->SubForum->read();
$this->set('subForum', $subForum);
$this->set('title_for_layout', 'Forums • ' . $subForum['SubForum']['name']);
$this->set('subForumName', $subForum['SubForum']['name']);
$this->set('threads', $this->paginate('SubForum.Thread'));
if (AuthComponent::User('role') == '3') {
$this->render('admin_display_topics');
}
}
示例7: canPostHere
public function canPostHere($id = null)
{
$subForumRole = $this->field('role', array('id' => $id));
return AuthComponent::User('role') >= $subForumRole;
}
示例8: editThread
public function editThread($data = null, $threadId = null)
{
$this->set($data);
$this->set('lasteditor', AuthComponent::User('id'));
if ($this->save($this->data)) {
if ($data[$this->alias]['notification']) {
$this->Notification->deleteAll(array('thread_id' => $this->id, 'user_id' => AuthComponent::User('id')));
$this->Notification->addNotification($threadId);
} else {
$this->Notification->deleteAll(array('thread_id' => $this->id, 'user_id' => AuthComponent::User('id')));
}
return true;
}
return false;
}
示例9: isAuthorized
public function isAuthorized($user)
{
return AuthComponent::User('role') >= '1' ? true : false;
}
示例10: isOwnedBy
public function isOwnedBy($messageId)
{
return $this->field('id', array('id' => $messageId, 'user_id' => AuthComponent::User('id'))) == $messageId;
}