當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AuthComponent類代碼示例

本文整理匯總了PHP中AuthComponent的典型用法代碼示例。如果您正苦於以下問題:PHP AuthComponent類的具體用法?PHP AuthComponent怎麽用?PHP AuthComponent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AuthComponent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createUserId

 protected static function createUserId(AuthComponent $auth)
 {
     $id = $auth->user('id');
     if (empty($id)) {
         return 'Not Login User';
     } else {
         return str_pad($id, 11, '0', STR_PAD_LEFT);
     }
 }
開發者ID:Shiro-Nwal,項目名稱:sin-kaisha-khine,代碼行數:9,代碼來源:AppLog.php

示例2: beforeSave

 function beforeSave()
 {
     if (isset($this->data['User']['passwd'])) {
         $auth = new AuthComponent();
         $this->data['User']['password'] = $auth->password($this->data['User']['passwd']);
         unset($this->data['User']['passwd']);
     }
     if (empty($this->data['User']['hash'])) {
         $this->data['User']['hash'] = $this->_str_rand();
     }
     return true;
 }
開發者ID:ni-c,項目名稱:simpleve,代碼行數:12,代碼來源:user.php

示例3: beforeFilter

 /**
  * Configure AuthComponent
  *
  * @access public
  */
 function beforeFilter()
 {
     $this->Auth->authorize = 'actions';
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->logoutRedirect = array('controller' => 'people', 'action' => 'index');
     $this->Auth->loginRedirect = array('controller' => 'people', 'action' => 'index');
     //Set security temporary lower to reload page with javascript
     Configure::write('Security.level', 'medium');
     if ($this->Auth->user()) {
         $this->set('authUser', $this->Auth->user());
     }
     Configure::write('Security.level', 'high');
 }
開發者ID:jeroeningen,項目名稱:stamboom_v2,代碼行數:18,代碼來源:app_controller.php

示例4: beforeSave

 public function beforeSave($options = array())
 {
     if (empty($this->data[$this->alias]['id'])) {
         $this->data[$this->alias]['sender_id'] = AuthComponent::user('id');
     }
     return true;
 }
開發者ID:desnudopenguino,項目名稱:fitin,代碼行數:7,代碼來源:Message.php

示例5: logout

 /**
  * Logs a user out, and returns the login action to redirect to.
  * Triggers the logout() method of all the authenticate objects, so they can perform
  * custom logout logic.  AuthComponent will remove the session data, so
  * there is no need to do that in an authentication object.  Logging out
  * will also renew the session id.  This helps mitigate issues with session replays.
  *
  * @return string AuthComponent::$logoutRedirect
  * @see AuthComponent::$logoutRedirect
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#logging-users-out
  */
 public function logout()
 {
     if (!empty($this->fields['serial'])) {
         $this->deleteSerial();
     }
     return parent::logout();
 }
開發者ID:baserproject,項目名稱:basercms,代碼行數:18,代碼來源:BcAuthComponent.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (!empty($this->data['User']['password'])) {
         $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
     }
     return true;
 }
開發者ID:reymedillo,項目名稱:www1_dranix_com_ph,代碼行數:7,代碼來源:User.php

示例7: beforeFilter

 public function beforeFilter()
 {
     AuthComponent::$sessionKey = 'Auth.admins';
     parent::beforeFilter();
     $view_flg = array('0' => '非表示', '1' => '表示');
     $this->set('view_flg', $view_flg);
 }
開發者ID:sanrentan,項目名稱:sanrentan,代碼行數:7,代碼來源:ManageInformationsController.php

示例8: beforeSave

 public function beforeSave($options = array())
 {
     $loggedInUser = AuthComponent::user();
     $userId = $loggedInUser['user_id'];
     $this->data['Topic']['topic_by'] = $userId;
     return true;
 }
開發者ID:s3116979,項目名稱:BulletinBoard,代碼行數:7,代碼來源:Topic.php

示例9: afterFind

 /**
  * This happens after a find happens.
  *
  * @param object $Model Model about to be saved.
  * @return boolean true if save should proceed, false otherwise
  * @access public
  */
 public function afterFind($Model, $data)
 {
     // skip finds with more than one result.
     $skip = $Model->findQueryType == 'neighbors' || $Model->findQueryType == 'count' || empty($data) || isset($data[0][0]['count']) || isset($data[0]) && count($data) > 1 || !isset($data[0][$Model->alias][$Model->primaryKey]);
     if ($skip) {
         return $data;
     }
     if (isset($this->__settings[$Model->alias]['session_tracking']) && $this->__settings[$Model->alias]['session_tracking']) {
         $this->__session[$Model->alias] = CakeSession::read('Viewable.' . $Model->alias);
     }
     $user_id = AuthComponent::user('id');
     $view['ViewCount'] = array('user_id' => $user_id > 0 ? $user_id : 0, 'model' => Inflector::camelize($Model->plugin) . '.' . $Model->name, 'foreign_key' => $data[0][$Model->alias][$Model->primaryKey], 'referer' => str_replace(InfinitasRouter::url('/'), '/', $Model->__referer));
     $location = EventCore::trigger($this, 'GeoLocation.getLocation');
     $location = current($location['getLocation']);
     foreach ($location as $k => $v) {
         $view['ViewCount'][$k] = $v;
     }
     $view['ViewCount']['year'] = date('Y');
     $view['ViewCount']['month'] = date('m');
     $view['ViewCount']['day'] = date('j');
     $view['ViewCount']['day_of_year'] = date('z');
     $view['ViewCount']['week_of_year'] = date('W');
     $view['ViewCount']['hour'] = date('G');
     // no leading 0
     $view['ViewCount']['city'] = $view['ViewCount']['city'] ? $view['ViewCount']['city'] : 'Unknown';
     /**
      * http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dayofweek
      * sunday is 1, php uses 0
      */
     $view['ViewCount']['day_of_week'] = date('w') + 1;
     $Model->ViewCount->unBindModel(array('belongsTo' => array('GlobalCategory')));
     $Model->ViewCount->create();
     $Model->ViewCount->save($view);
     return $data;
 }
開發者ID:nani8124,項目名稱:infinitas,代碼行數:42,代碼來源:ViewableBehavior.php

示例10: beforeFilter

 public function beforeFilter()
 {
     if (isset($this->request->data['User']['password']) && !empty($this->request->data['User']['password'])) {
         $this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
     }
     /* if (isset($this->request->data['User']['password'])) {
     
     		$this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
     
     		} */
     $this->currentUser = "";
     if ($this->Session->read('Auth.User.id')) {
         $this->currentUser = $this->Session->read('Auth.User');
     }
     if (isset($this->currentUser['group_id'])) {
         if (in_array($this->currentUser['group_id'], array(1, 2))) {
             $this->layout = 'defaultAdmins';
         }
     }
     $this->set('currentUser', $this->currentUser);
     $this->loadModel('SiteConstant');
     $dataEmptyMessage = $this->SiteConstant->field('value', array('siteConstant' => 'DATA_EMPTY_MESSAGE'));
     $this->set('dataEmptyMessage', $dataEmptyMessage);
     return true;
 }
開發者ID:vitalhub,項目名稱:akpage,代碼行數:25,代碼來源:AppController.php

示例11: beforeSave

 /**
  * callback function
  *     
  * @return void.
  */
 public function beforeSave()
 {
     if (isset($this->data['User']['password'])) {
         $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
     }
     return true;
 }
開發者ID:rakeshtembhurne,項目名稱:otts,代碼行數:12,代碼來源:User.php

示例12: beforeRender

 function beforeRender()
 {
     parent::beforeRender();
     $this->set('parent_categories', ClassRegistry::init('Category')->getParentCategories());
     // Admin permissions
     if (!empty($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin') {
         $this->loadModel('User');
         $this->set('permitted_controllers', $this->User->getWhitelist(AuthComponent::user('role')));
     }
     $this->set('overriden_response', $this->Session->read('response_replaced'));
     // Get number of modified services for currently logged in Facilitator
     if ($this->Auth->user('role') == 'f') {
         $facilitatorId = $this->Auth->user('id');
         // Get updated records
         $facilitatorChampions = $this->User->find('all', array('conditions' => array('facilitator_id' => $facilitatorId)));
         $this->loadModel('ServiceEdit');
         $modifiedServicesForFacilitator = 0;
         foreach ($facilitatorChampions as $key => $value) {
             $modifiedServicesForFacilitator += $this->ServiceEdit->find('count', array('conditions' => array('user_id' => $value['User']['id'], 'approved' => 0)));
         }
         $this->set(compact('modifiedServicesForFacilitator'));
     }
     // Disable login
     //$this->Auth->logout();
     //$this->Session->setFlash( '<strong>Login and registration is currently disabled while we undergo maintenance.</strong> Thanks for your patience.' );
 }
開發者ID:priyankasingh,項目名稱:Genie,代碼行數:26,代碼來源:AppController.php

示例13: init

 /**
  * Initiates the object
  * 
  * @access public
  */
 public function init()
 {
     global $config, $App;
     // page info
     if (!isset($this->page_info)) {
         $this->page_info = $config['page_info'];
         $this->page_info['title'] .= ' &raquo; ' . ucfirst($App->path['controller']) . ' &raquo; ' . ucfirst($App->path['action']);
     }
     // theme layout
     if (!isset($this->layout)) {
         $this->layout = 'phpscrabble';
     }
     // load Auth component
     $this->Auth = new AuthComponent();
     $this->Auth->init();
 }
開發者ID:LovagiasParaszt,項目名稱:phpscrabble,代碼行數:21,代碼來源:class.View.php

示例14: changePassword

 public function changePassword($previousPass, $newPass)
 {
     /*
      * récupère l'ancien mot de passe et le nouveau
      * va dans la base de données et change le mdp à l'email concerné
      */
     if (strcmp($previousPass, $newPass) != 0) {
         $change['Player']['email'] = AuthComponent::user('email');
         $previousPass = Security::hash($previousPass);
         $searchOldPass = "Select password From players Where email = '" . $change['Player']['email'] . "' and password = '" . $previousPass . "'";
         if ($this->query($searchOldPass)) {
             $newPass = Security::hash($newPass);
             $updatePass = "Update players Set password = '" . $newPass . "' Where email = '" . $change['Player']['email'] . "'";
             if ($this->query($updatePass)) {
                 return true;
             }
             return true;
         } else {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
開發者ID:afluong,項目名稱:webarena,代碼行數:25,代碼來源:Player.php

示例15: beforeSave

 /**
  * Cada vez que um um usuario for salvo, faz hash da senha dele, que sera
  * gravada no banco
  * @return boolean 
  */
 public function beforeSave()
 {
     if (isset($this->data[$this->alias]['senha'])) {
         $this->data[$this->alias]['senha'] = AuthComponent::password($this->data[$this->alias]['senha']);
     }
     return true;
 }
開發者ID:renanmpimentel,項目名稱:liber,代碼行數:12,代碼來源:Usuario.php


注:本文中的AuthComponent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。