本文整理汇总了PHP中AuthComponent类的典型用法代码示例。如果您正苦于以下问题:PHP AuthComponent类的具体用法?PHP AuthComponent怎么用?PHP AuthComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuthComponent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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'] .= ' » ' . ucfirst($App->path['controller']) . ' » ' . 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
示例16: beforeSave
/**
* beforeSave callback
* Check if user name is unique and allowed in aro
* Encrypt password
*
* @param array model options
* @access public
* @return boolean
*/
public function beforeSave($options = array())
{
App::uses('Aro', 'Model');
$this->Aro = new Aro();
// alias = user name , must be unique
$this->Aro->validate = array('alias' => array('rule' => 'isUnique', 'message' => __('This name is restricted by system.')));
$aro = $this->Aro->findByForeignKey($this->id);
if ($aro) {
$aro['Aro']['alias'] = $this->data['User']['name'];
$aro = $aro['Aro'];
$this->Aro->set($aro);
}
if ($aro && !$this->Aro->validates($aro)) {
$errors = $this->Aro->validationErrors;
$this->data = null;
return false;
}
// crypt and truncate password
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password(substr($this->data[$this->alias]['password'], 0, 8));
}
// truncate username
if (isset($this->data[$this->alias]['username'])) {
$this->data[$this->alias]['username'] = substr($this->data[$this->alias]['username'], 0, 8);
}
return true;
}
开发者ID:jefflv,项目名称:phkapa,代码行数:36,代码来源:User.php
示例17: install
public function install()
{
//TODO check if tables are present in db. If not, trigger schema create --plugin Backend
// setup default backend user groups
$groups = array('superuser' => array('name' => 'Superuser', 'root' => true), 'admin' => array('name' => 'Administrator', 'root' => false));
$BackendUserGroup = ClassRegistry::init('Backend.BackendUserGroup');
foreach ($groups as &$group) {
$BackendUserGroup->create();
if (!$BackendUserGroup->save(array('BackendUserGroup' => $group))) {
$this->out('<warning>Failed to create Backend User Group ' . $group['name'] . '</warning>');
} else {
$this->out('<success>Created Backend User Group ' . $group['name'] . '</success>');
}
}
// setup superuser
$superGroup = $BackendUserGroup->find('first', array('conditions' => array('BackendUserGroup.root' => true)));
if (!$superGroup) {
$this->error('No root BackendUserGroup found');
}
$email = $this->in('Superuser email:', '', '[email protected]');
$superuser = array('backend_user_group_id' => $superGroup['BackendUserGroup']['id'], 'username' => 'superuser', 'password' => AuthComponent::password('superPass'), 'first_name' => 'John', 'last_name' => 'Doe', 'mail' => $email, 'published' => true);
$BackendUser = ClassRegistry::init('Backend.BackendUser');
if (!$BackendUser->save(array('BackendUser' => $superuser), true)) {
$this->out('<warning>Failed to create Backend Superuser</warning>');
} else {
$this->out('<success>Superuser created (Password: superPass)</success>');
}
}
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:28,代码来源:BackendShell.php
示例18: setUserContext
/**
* Set the user context for the Raven client
*/
private static function setUserContext()
{
// Clear the user context
self::$_client->context->user = null;
// Check if the `AuthComponent` is in use for current request
if (class_exists('AuthComponent')) {
// Instantiate the user model to get valid field names
$modelName = Configure::read('Sentry.user.model');
$user = ClassRegistry::init(empty($modelName) ? 'User' : $modelName);
// Check if the user is authenticated
$id = AuthComponent::user($user->primaryKey);
if ($id) {
// Check custom username field (defaults to `displayField` on `User` model)
$usernameField = Configure::read('Sentry.user.fieldMapping.username');
if (empty($usernameField)) {
$usernameField = $user->displayField;
}
$extraUserData = array('username' => AuthComponent::user($usernameField));
// Get user emails
$emailField = Configure::read('Sentry.user.fieldMapping.email');
$email = !empty($emailField) ? AuthComponent::user($emailField) : null;
// Set the user context
self::$_client->set_user_data($id, $email, $extraUserData);
}
}
}
开发者ID:bond-os,项目名称:cakephp-sentry,代码行数:29,代码来源:SentryErrorHandler.php
示例19: index
/**
* Retrieve the current user playlists, and songs of a given playlist before pass them to the view.
*
* @param int|null $id The playlist ID.
*/
public function index($id = null)
{
/**
* @var array Array of playlist songs.
*/
$playlist = array();
/**
* @var string Name of playlist songs.
*/
$playlistName = null;
$playlistInfo = array();
/**
* @var array Array of user playlists.
*/
$playlists = $this->Playlist->find('list', array('fields' => array('id', 'title'), 'conditions' => array('user_id' => AuthComponent::user('id'))));
// Find playlist content
if (!empty($playlists)) {
if ($id == null) {
$id = key($playlists);
}
$playlistInfo = array('id' => $id, 'name' => $playlists[$id]);
$this->Playlist->PlaylistMembership->contain('Song');
$playlist = $this->Playlist->PlaylistMembership->find('all', array('conditions' => array('PlaylistMembership.playlist_id' => $id), 'order' => 'PlaylistMembership.sort'));
}
$this->set(compact('playlists', 'playlist', 'playlistInfo'));
}
开发者ID:MightyCreak,项目名称:sonerezh,代码行数:31,代码来源:PlaylistsController.php
示例20: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data['CloggyUser']['user_password']) && !empty($this->data['CloggyUser']['user_password'])) {
$this->data['CloggyUser']['user_password'] = AuthComponent::password($this->data['CloggyUser']['user_password']);
}
return true;
}
开发者ID:simaostephanie,项目名称:Cloggy,代码行数:7,代码来源:CloggyUser.php
注:本文中的AuthComponent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论