本文整理汇总了PHP中AuthComponent::sessionKey方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthComponent::sessionKey方法的具体用法?PHP AuthComponent::sessionKey怎么用?PHP AuthComponent::sessionKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthComponent
的用法示例。
在下文中一共展示了AuthComponent::sessionKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFilter
function beforeFilter()
{
$this->BlowFish = new BlowfishPasswordHasher();
if ($this->request->prefix == "admin") {
//Security::setHash('md5');
AuthComponent::$sessionKey = 'Auth.Admin';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'admin_login');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'admin_dashboard');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'admin_login');
$this->Auth->authenticate = array('Form' => array('userModel' => 'User', 'passwordHasher' => 'Blowfish', 'fields' => array('username' => 'email', 'password' => 'password'), 'scope' => array('User.role' => 'Admin')));
if (!$this->Auth->loggedIn()) {
$this->Auth->authError = false;
}
$this->Auth->allow('admin_login');
$this->layout = 'admin_default';
}
if ($this->request->prefix == "") {
//Security::setHash('md5');
AuthComponent::$sessionKey = 'Auth.User';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'dashboard');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
$this->Auth->authenticate = array('Form' => array('userModel' => 'User', 'passwordHasher' => 'Blowfish', 'fields' => array('username' => 'email', 'password' => 'password'), 'scope' => array('User.role' => 'User')));
if (!$this->Auth->loggedIn()) {
$this->Auth->authError = false;
}
$this->Auth->allow('login');
$this->layout = 'default';
}
}
示例2: beforeFilter
public function beforeFilter()
{
AuthComponent::$sessionKey = 'Auth.admins';
parent::beforeFilter();
$view_flg = array('0' => '非表示', '1' => '表示');
$this->set('view_flg', $view_flg);
}
示例3: beforeFilter
public function beforeFilter()
{
if (!$this->ControleDeAcesso->validaAcessoAcao()) {
//$this->Session->setFlash('<strong>Atenção!</strong> Você não tem permissão para acessar esta página.', 'danger');
//$this->redirect(array('controller'=>'principal','action'=>'index'));
}
AuthComponent::$sessionKey = "Auth.Indicadores";
Security::setHash('md5');
}
示例4: beforeFilter
public function beforeFilter()
{
$this->Cookie->httpOnly = true;
$this->Cookie->type('aes');
if (isset($this->request->params['advisor']) && $this->request->params['advisor']) {
// Setup authentication for Advisor
$this->Auth->loginRedirect = array('controller' => 'accounts', 'action' => 'mypage', 'advisor' => true);
$this->Auth->logoutRedirect = array('controller' => 'top', 'action' => 'index', 'advisor' => false);
$this->Auth->loginAction = array('controller' => 'accounts', 'action' => 'login', 'advisor' => true);
$this->Auth->authenticate = array('Form' => array('passwordHasher' => 'Blowfish', 'userModel' => 'Advisor', 'fields' => array('username' => 'mail_address'), 'scope' => array('Advisor.delete_flag' => 0), 'contain' => array('AdvisorProfile.fullname', 'AdvisorProfile.image_url')));
AuthComponent::$sessionKey = 'Auth.Advisor';
if (!$this->Auth->loggedIn()) {
$cookie = $this->Cookie->read('advisor_remember_me_cookie');
if ($cookie) {
$this->loadModel('Advisor');
$advisor = $this->Advisor->find('first', array('recursive' => -1, 'conditions' => array('Advisor.mail_address' => $cookie['mail_address'], 'Advisor.password' => $cookie['password'])));
if ($advisor && !$this->Auth->login($advisor['Advisor'])) {
$this->redirect(array('controller' => 'accounts', 'action' => 'logout'));
// destroy session & cookie
}
}
}
$this->__getUnreadMessage();
} elseif (isset($this->request->params['admin']) && $this->request->params['admin']) {
$this->helpers['Form'] = array('className' => 'BoostCake.BoostCakeForm');
$this->helpers['Html'] = array('className' => 'BoostCake.BoostCakeHtml');
// Setup authentication for Admin
$this->Auth->loginRedirect = '/admin/';
$this->Auth->logoutRedirect = array('controller' => 'admin_login', 'action' => 'login', 'admin' => true);
$this->Auth->loginAction = array('controller' => 'admin_login', 'action' => 'login', 'admin' => true);
$this->Auth->authenticate = array('Form' => array('passwordHasher' => 'Blowfish', 'userModel' => 'Administrator', 'fields' => array('username' => 'mail_address'), 'scope' => array('Administrator.delete_flag' => 0)));
AuthComponent::$sessionKey = 'Auth.Admin';
$this->layout = 'admin';
} else {
// Setup authentication for USER
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'mypage');
$this->Auth->logoutRedirect = '/';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->authenticate = array('Form' => array('passwordHasher' => 'Blowfish', 'userModel' => 'User', 'fields' => array('username' => 'mail_address'), 'scope' => array('User.delete_flag' => 0), 'contain' => array('UserProfile.fullname', 'UserProfile.image_url')));
AuthComponent::$sessionKey = 'Auth.User';
if (!$this->Auth->loggedIn()) {
$cookie = $this->Cookie->read('user_remember_me_cookie');
if ($cookie) {
$this->loadModel('User');
$user = $this->User->find('first', array('recursive' => -1, 'conditions' => array('User.mail_address' => $cookie['mail_address'], 'User.password' => $cookie['password'])));
if ($user && !$this->Auth->login($user['User'])) {
$this->redirect(array('controller' => 'users', 'action' => 'logout'));
// destroy session & cookie
}
}
}
$this->__getUnreadMessage();
}
}
示例5: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
AuthComponent::$sessionKey = 'Auth.Manager';
$this->Auth->allow('login');
$this->layout = 'Admin.admin';
if ($this->Session->read('Auth.Manager')) {
$user['id'] = $this->Session->read('Auth.Manager.id');
$user['username'] = $this->Session->read('Auth.Manager.username');
$this->set('user', $user);
}
}
示例6: beforeFilter
function beforeFilter(){
if(isset($this->params['prefix']) && $this->params['prefix'] == 'admin'){
$this->Auth->loginAction = array('controller'=>'admins', 'action'=>'sign_in');
AuthComponent::$sessionKey = 'Auth.Admin';
$this->layout = 'Admin/default';
}else{
$this->Auth->loginAction = array('controller'=>'users', 'action'=>'home');
if($this->Session->check('Auth.User.User.id'))
$this->layout = 'FrontEnd/Inner/default';
else
$this->layout = 'FrontEnd/default';
AuthComponent::$sessionKey = 'Auth.User';
}
}
示例7: initialize
/**
* Initialize Controller and CakeRequest
*
* This method applies Controller attributes.
* Should be called in Component::initialize() or Controller::beforeFilter()
*
* @param Controller $controller
* @param CakeRequest $request
* @return boolean
*/
public function initialize(Controller $controller)
{
// attach event listeners
$controller->getEventManager()->attach(new BackendEventListener());
// add backend detector
$controller->request->addDetector('backend', array('callback' => array($this, 'isBackendRequest')));
$controller->request->addDetector('iframe', array('callback' => array($this, 'isIframeRequest')));
// is a plugin using backend?
if ($controller->request->params['plugin']) {
$this->plugin = $controller->request->params['plugin'];
}
if ($controller->request->is('backend')) {
$this->_isBackendRequest = true;
// Load plugin specif config
if ($this->plugin && $this->plugin != "backend") {
try {
Configure::load(Inflector::camelize($this->plugin) . '.backend');
} catch (Exception $e) {
// this plugin has no backend configuration
}
}
// Controller
$controller->layout = $this->layout;
$controller->viewClass = 'Backend.Backend';
// load AuthComponent
if (Configure::read('Backend.Auth.enabled') === true && !$controller->Components->loaded('Auth')) {
$controller->Auth = $controller->Components->load('Auth');
$controller->Auth->initialize($controller);
}
// Auth
if (Configure::read('Backend.Auth.enabled') === true && $controller->Auth) {
//TODO check if backend auth sessionkey overwrite can be avoided
AuthComponent::$sessionKey = "Auth.Backend";
$controller->Auth->authenticate = $this->authenticate;
$controller->Auth->loginAction = $this->loginAction;
// enable Access Control List
if (Configure::read('Backend.Acl.enabled') === true) {
//TODO check if acl tables are present
$controller->Auth = $this->authorize;
}
}
// Error Handling
if (is_a($controller, 'CakeErrorController')) {
// use backend error layout
$controller->layout = $this->errorLayout;
}
}
}
示例8: authComponentConfig
/**
* Configurações necessarias para o componente
* de autenticação de usuário, AuthComponent
*/
private function authComponentConfig()
{
// Índice onde será salvo as informações de sessão do usuário. Este deve
// ser único, para que não ocorra colisão de sessões de outras aplicações
// que utilizam está mesma base.
// Pode-se basear pelo nome da aplicação e o IP do cliente.
AuthComponent::$sessionKey = PROJECT_NAME . str_replace('.', '', $this->RequestHandler->getClientIp());
$this->Auth->authenticate = array(AuthComponent::ALL => array('userModel' => 'User', 'fields' => array('username' => 'email'), 'scope' => array('User.enable' => TRUE)), 'Form');
$this->Auth->authorize = 'Controller';
$this->Auth->loginAction = array('controller' => 'Users', 'action' => 'login', 'prefix' => 'visitor');
$this->Auth->logoutRedirect = array('controller' => 'Users', 'action' => 'login', 'prefix' => 'visitor');
$this->Auth->flash['element'] = 'flash/mini/error';
// Caso o prefixo de uma ação requisitada pela URL seja
// igual a hierarqui do usuaŕio, devemos permitir sua execução.
if ($this->request->prefix == SupportComponent::userHierarchy()) {
$this->Auth->allow($this->request->action);
}
}
示例9: beforeFilter
public function beforeFilter()
{
$controller = $this->params['controller'];
$action = $this->params['action'];
$this->set("controller", $controller);
$this->set("action", $action);
if (isset($this->request->params['admin'])) {
$this->layout = 'admin';
AuthComponent::$sessionKey = 'Auth.Admin';
$this->Auth->loginAction = array('admin' => true, 'controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('admin' => true, 'controller' => 'users', 'action' => 'dashboard');
$this->Auth->logoutRedirect = array('admin' => true, 'controller' => 'users', 'action' => 'login');
}
if ($this->RequestHandler->isAjax()) {
$this->layout = 'ajax';
}
$this->SiteSettings();
$this->Auth->authorize = array('Controller');
}
示例10: beforeFilter
function beforeFilter()
{
/* if($_SERVER['HTTP_HOST'] == 'fusedpage.ca'){
$siteRedirectUrl = 'http://fusedpage.com'.$_SERVER['REQUEST_URI'];
$this->redirect($siteRedirectUrl);
} */
//$this->Session->write('Auth.User.User.social_facebook', '1');
if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
$this->Auth->loginAction = array('controller' => 'admins', 'action' => 'sign_in');
AuthComponent::$sessionKey = 'Auth.Admin';
$this->layout = 'Admin/default';
} else {
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'home');
if ($this->Session->check('Auth.User.User.id')) {
$this->layout = 'FrontEnd/Inner/default';
} else {
$this->layout = 'FrontEnd/default';
}
AuthComponent::$sessionKey = 'Auth.User';
}
}
示例11: _manageAuthConfigs
private function _manageAuthConfigs()
{
$this->Auth->authError = 'Área restrita, identifique-se primeiro.';
$this->Auth->authorize = array('Controller');
$this->Auth->flash = array_merge($this->Auth->flash, array('element' => 'alerts/inline', 'params' => array('class' => 'error')));
AuthComponent::$sessionKey = 'Auth.Customer';
$this->Auth->loginAction = array('controller' => 'customers', 'action' => 'login', 'customer' => true);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->authenticate = array('Form' => array('userModel' => 'Customer', 'fields' => array('username' => 'email')));
if ($this->isPrefix('admin')) {
AuthComponent::$sessionKey = 'Auth.Admin';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => true);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/login';
$this->Auth->authenticate = array('Form' => array('userModel' => 'User', 'scope' => array('status' => '1')));
$this->Auth->allow('login');
} elseif ($this->isPrefix('customer')) {
$this->Auth->deny();
} else {
$this->Auth->allow();
}
}
示例12: initialize
public function initialize(Controller $Controller, $settings = array())
{
$this->controller = $Controller;
$this->isBrwPanel = (!empty($Controller->request->params['prefix']) and $Controller->request->params['prefix'] == 'brw' or $Controller->params['plugin'] == 'brownie');
ClassRegistry::init('BrwUser')->Behaviors->attach('Brownie.BrwUser');
ClassRegistry::init('BrwImage')->Behaviors->attach('Brownie.BrwUpload');
ClassRegistry::init('BrwFile')->Behaviors->attach('Brownie.BrwUpload');
if (!empty($Controller->request->params['prefix']) and $Controller->request->params['prefix'] == 'brw') {
if (!class_exists('AuthComponent')) {
$Controller->Components->load('Auth', Configure::read('brwAuthConfig'));
} else {
foreach (Configure::read('brwAuthConfig') as $key => $value) {
$Controller->Auth->{$key} = $value;
}
}
App::build(array('views' => ROOT . DS . APP_DIR . DS . 'Plugin' . DS . 'Brownie' . DS . 'View' . DS));
$Controller->helpers[] = 'Js';
$Controller->layout = 'brownie_default';
if (!empty($Controller->modelClass)) {
$Controller->{$Controller->modelClass}->attachBackend();
}
}
if ($this->isBrwPanel) {
AuthComponent::$sessionKey = 'Auth.BrwUserLogged';
$this->_menuConfig();
}
if (Configure::read('Config.languages')) {
$langs3chars = array();
$l10n = new L10n();
foreach ((array) Configure::read('Config.languages') as $lang) {
$catalog = $l10n->catalog($lang);
$langs3chars[$lang] = $catalog['localeFallback'];
}
Configure::write('Config.langs', $langs3chars);
}
}
示例13: testStatelessAuthNoSessionStart
/**
* testStatelessAuthNoSessionStart method
*
* @return void
*/
public function testStatelessAuthNoSessionStart()
{
if (CakeSession::id()) {
session_destroy();
CakeSession::$id = null;
}
$_SESSION = null;
$_SERVER['PHP_AUTH_USER'] = 'mariano';
$_SERVER['PHP_AUTH_PW'] = 'cake';
AuthComponent::$sessionKey = false;
$this->Auth->authenticate = array('Basic' => array('userModel' => 'AuthUser'));
$this->Controller->request['action'] = 'admin_add';
$result = $this->Auth->startup($this->Controller);
$this->assertTrue($result);
$this->assertNull(CakeSession::id());
}
示例14: beforeFilter
public function beforeFilter()
{
AuthComponent::$sessionKey = 'Auth.admins';
parent::beforeFilter();
}
示例15: beforeFilter
/**
* To filter url request
* @author Gaurav
*/
public function beforeFilter()
{
$headersInformation = getallheaders();
// admin email
$this->set('AdminEmail', AdminEmail);
if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
//$this->Auth->loginRedirect = array('plugin' => false, 'controller' => 'dashboard', 'action' => 'index');
$this->layout = 'admin';
AuthComponent::$sessionKey = 'Auth.User';
$this->isAdmin = TRUE;
Configure::write('isAdmin', TRUE);
} else {
//$this->Auth->loginRedirect = array('plugin' => false, 'controller' => 'pages', 'action' => 'home');
$this->layout = 'front';
// get group change request status
$bizOwnerId = $this->Session->read('Auth.Front.BusinessOwners.id');
//$crCount = $this->Session->read('Auth.Front.BusinessOwners.group_change');
//$this->set(compact('crCount'));
Configure::write('isAdmin', FALSE);
AuthComponent::$sessionKey = 'Auth.Front';
}
$roleType = $this->Session->read('Auth.User.user_type');
$this->set('common', $this->Common);
$frontUserRole = $this->Session->read('Auth.Front.user_type');
$isUserLogin = $frontUserRole == "businessOwner" ? true : false;
$this->set(compact("isUserLogin"));
$loginUserId = $this->Session->read('Auth.Front.id');
$this->set(compact("loginUserId"));
if (empty($headersInformation['HASHKEY']) && $this->params['prefix'] != 'api') {
// redirect session after login
$checkUrl = Router::fullbaseUrl() . $this->here;
if (strpos($checkUrl, Configure::read('SITE_URL') . 'referrals/referralDetails/sent/') !== false) {
$this->Session->write('BackUrlAfterLogin', $checkUrl);
} elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'referrals/referralDetails/received/') !== false) {
$this->Session->write('BackUrlAfterLogin', $checkUrl);
} elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'messages/viewMessage/') !== false) {
$this->Session->write('BackUrlAfterLogin', $checkUrl);
} elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'reviews/index') !== false) {
$this->Session->write('BackUrlAfterLogin', $checkUrl);
} elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'meetings') !== false) {
$this->Session->write('BackUrlAfterLogin', $checkUrl);
}
if (empty($roleType)) {
$this->Auth->allow(array('admin_login', 'admin_forgotPassword', 'admin_resetPassword', 'home', 'login', 'subscribe', 'aboutUs', 'contactUs', 'privacyPolicy', 'termsOfServices', 'careers', 'partners', 'faq', 'faqView', 'faqSearch', 'getCountryList', 'getCountryName', 'getStateList', 'getStateName', 'trainingVideoReminderMail', 'recurringTransaction', 'rating', 'deactivateUser', 'getProfessionList'));
}
} else {
if ($this->params['prefix'] == 'api') {
$this->RequestHandler->ext = Configure::read('SERVICEFORMAT');
if (!isset($headersInformation['HASHKEY']) || $headersInformation['HASHKEY'] != Configure::read('HASHKEY')) {
echo json_encode(array('code' => Configure::read('RESPONSE_ERROR'), 'message' => 'Invalid Hash Key'));
die;
}
$this->Auth->allow($this->action);
//API Post Data in Json
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->__getPostContent();
}
//fetch the headers data
$this->__getHeaderInformation();
}
}
// Login user get counter for different entity (ex- message, referrals etc.)
if (empty($this->request->data) && empty($this->request->form)) {
$this->Common->clearDropzoneData();
}
$messageCounter = 0;
$referalCounter = 0;
if ($loginUserId != "") {
$loginUserId = $this->Encryption->decode($loginUserId);
$userGroup = $this->Groups->getUserGroupId($loginUserId);
// logout user after shuffling
$beforeShuffling = $this->Session->read('Auth.Front.BusinessOwner.group_id');
$afterShuffling = $userGroup['BusinessOwner']['group_id'];
if (!empty($beforeShuffling) && $beforeShuffling != $afterShuffling) {
$this->Auth->logout();
}
if ($this->action == "viewMessage") {
if (isset($this->params->pass[0])) {
$messageId = $this->Encryption->decode($this->params->pass[0]);
$this->loadModel('MessageRecipient');
$this->MessageRecipient->updateAll(array('MessageRecipient.is_read' => 1, 'MessageRecipient.is_total_read' => 1), array('MessageRecipient.message_id' => $messageId, 'MessageRecipient.recipient_user_id' => $loginUserId));
}
}
if ($this->action == "referralDetails") {
if (isset($this->params->pass[0]) && isset($this->params->pass[1])) {
if ($this->params->pass[0] == "received") {
$referralId = $this->Encryption->decode($this->params->pass[1]);
$this->loadModel('ReceivedReferral');
$this->ReceivedReferral->updateAll(array('ReceivedReferral.is_read' => 1, 'ReceivedReferral.is_total_read' => 1), array('ReceivedReferral.id' => $referralId, 'ReceivedReferral.to_user_id' => $loginUserId));
}
}
}
$messageCounter = $this->Common->unreadCounter('messages', $loginUserId);
$referalCounter = $this->Common->unreadCounter('referrals', $loginUserId);
$this->set('userGroup', $userGroup['BusinessOwner']['group_id']);
// get profile picture path
//.........这里部分代码省略.........