private function getUserSession() { App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $user = $Session->read('UserAuth'); return $user; }
public function beforeFind($queryData) { $res = parent::beforeFind($queryData); /* if(AuthComponent::user('id') == 1) { return $queryData; } */ App::import('Model', 'CakeSession'); $session = new CakeSession(); $userAvailableTags = $session->read('Rights.UserAvailablesTags'); $userForbiddenTags = $session->read('Rights.UserForbiddenTags'); $userAvailableAlbums = $session->read('Rights.UserAvailablesAlbums'); $userForbiddenAlbums = $session->read('Rights.UserForbiddenAlbums'); if (count($userForbiddenAlbums) != 0) { // $queryData['conditions']['Image.album'] = 'not in ('.implode(',', $userForbiddenAlbums).')'; } /* App::import('Model', 'ImageTag'); $imageTag = new ImageTag(); $subSqlQuery = $imageTag->find('sql', array('fields'=>'imageid','conditions'=>'tagid not in ('.implode(',', $userForbiddenTags).')')); */ if (count($userForbiddenTags) != 0) { // $subSqlQuery = 'SELECT imageid from ImageTags where tagid not in ('.implode(',', $userForbiddenTags).')'; // $queryData['conditions']['Image.id'] = 'not in ('.$subSqlQuery.')'; } // debug($queryData); return $queryData; }
/** * Default Constructor * * @param array $config options * @access public */ public function __construct($config) { // _toPost keys are case sensitive for google api, changin them will result in bad authentication $_toPost['accountType'] = $config['accounttype']; $_toPost['Email'] = $config['email']; $_toPost['Passwd'] = $config['passwd']; $_toPost['service'] = $config['service']; $_toPost['source'] = $config['source']; $this->HttpSocket = new HttpSocket(); // Initializing Cake Session $session = new CakeSession(); $session->start(); // Validating if curl is available if (function_exists('curl_init')) { $this->_method = 'curl'; } else { $this->_method = 'fopen'; } // Looking for auth key in cookie of google api client login $cookie_key = $session->read('GoogleClientLogin' . $_toPost['service'] . '._auth_key'); if ($cookie_key == null || $cookie_key == "") { // Geting auth key via HttpSocket $results = $this->HttpSocket->post($this->_login_uri, $_toPost); $first_split = split("\n", $results); foreach ($first_split as $string) { $arr = split("=", $string); if ($arr[0] == "Auth") { $this->_auth_key = $arr[1]; } } $session->write('GoogleClientLogin' . $_toPost['service'] . '._auth_key', $this->_auth_key); } else { $this->_auth_key = $cookie_key; } }
public function currentUser() { App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $user = $Session->read('Auth.User'); return array('id' => $user['User']['username']); }
protected function _getCurrentUser() { App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $user_id = $Session->read('Auth.User.User.id'); return $user_id; }
/** * 動画変換とデータ保存 MP4例外テスト * * @return void * @throws Exception */ public function testSaveConvertVideoMp4Exception() { // 暫定対応(;'∀') ffmpeg未インストールによる travis-ci error のため、コメントアウト //$this->setExpectedException('InternalErrorException'); // AuthComponent::user('id');対応 $Session = new CakeSession(); $Session->write('Auth.User.id', 1); $data = array('Video' => array('block_id' => 2)); $video = array('Video' => array('mp4_id' => 1), Video::VIDEO_FILE_FIELD => array('FilesPlugin' => array('plugin_key' => 'videos'))); $roomId = 1; // テストファイル準備 $contentsId = $video['Video']['mp4_id']; $fileName = 'video1.mp4'; $this->_readyTestFile($contentsId, $roomId, $fileName); // 例外を発生させるためのモック $videoMock = $this->getMockForModel('Videos.Video', ['save']); $videoMock->expects($this->any())->method('save')->will($this->returnValue(false)); $videoMock->FileModel = ClassRegistry::init('Files.FileModel'); try { // 動画変換とデータ保存 $videoMock->saveConvertVideo($data, $video, $roomId); } catch (Exception $e) { // テストファイル削除 $this->_deleteTestFile(); // 暫定対応(;'∀') ffmpeg未インストールによる travis-ci error のため、コメントアウト //throw $e; } }
public function getCurrentUser() { // for CakePHP 2.x: App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $user = $Session->read('Auth.User'); return $user; }
public function beforeSave($options = array()) { // if (isset($this->data[$this->alias]['user_id'])) { App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $this->data[$this->alias]['user_id'] = $Session->read('Auth.User.id'); //} return true; }
/** * ログインユーザーのデータを取得する * * @return array */ public static function loginUser($prefix = 'admin') { $Session = new CakeSession(); $sessionKey = BcUtil::authSessionKey($prefix); $user = $Session->read('Auth.' . $sessionKey); if (!$user) { if (!empty($_SESSION['Auth'][$sessionKey])) { $user = $_SESSION['Auth'][$sessionKey]; } } return $user; }
public function beforeSave($options = array()) { // a file has been uploaded so grab the filepath if (!empty($this->data[$this->alias]['picture'])) { $this->data[$this->alias]['picture'] = $this->path; } if (!isset($this->data[$this->alias]['user_id'])) { App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $this->data[$this->alias]['user_id'] = $Session->read('Auth.User.id'); } return parent::beforeSave($options); }
public function getCurrentUser($field = false) { App::uses('CakeSession', 'Model/Datasource'); $Session = new CakeSession(); $user = $Session->read('Auth.User'); if ($user && is_array($user)) { if ($field === false) { return $user; } else { return isset($user[$field]) ? $user[$field] : false; } } else { return false; } }
public function flash($key = 'flash', $attrs = array()) { $out = false; if (CakeSession::check('Message.' . $key)) { $flash = CakeSession::read('Message.' . $key); $message = $flash['message']; unset($flash['message']); if (!empty($attrs)) { $flash = array_merge($flash, $attrs); } if ($flash['element'] === 'default') { $class = 'success'; if (!empty($flash['params']['class'])) { $class = $flash['params']['class']; } $out = '<div id="' . $key . 'Message" class="alert alert-' . $class . '"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . $message . '</div>'; } elseif (!$flash['element']) { $out = $message; } else { $options = array(); if (isset($flash['params']['plugin'])) { $options['plugin'] = $flash['params']['plugin']; } $tmpVars = $flash['params']; $tmpVars['message'] = $message; $out = $this->_View->element($flash['element'], $tmpVars, $options); } CakeSession::delete('Message.' . $key); } return $out; }
/** * Check user is login or not and also setup user and other necessary veriable * * @param null * @return null */ private function validateLoginStatus() { $useridentity = CakeSession::read('User.identity'); if ($this->params['controller'] != 'admin_dashbords' && !in_array($this->params['action'], array('login'))) { if (empty($useridentity['User'])) { if (substr($this->params['controller'], 0, 6) == 'admin_') { $this->redirect('/admin/'); } else { //$this->redirect('/'); } } } $hasIdentity = !empty($useridentity['User']) ? true : false; $this->set('hasIdentity', $hasIdentity); $username = NULL; if (!$hasIdentity && ($this->params['controller'] != 'admin_dashbords' && $this->params['action'] != 'login')) { if (substr($this->params['controller'], 0, 6) == 'admin_') { $this->redirect('/admin/'); } else { //$this->redirect('/'); } } else { $username = ucfirst($useridentity['User']['user']); $this->set('username', $username); } if (!empty($useridentity)) { $this->useridentity->id = $useridentity['User']['id']; $this->useridentity->user = $useridentity['User']['user']; $this->useridentity->email = $useridentity['User']['email']; $this->useridentity->role_id = $useridentity['User']['role_id']; } }
/** * Check Auth is user is admin */ public function setup(Model $model, $settings = array()) { parent::setup($model, $settings); if (CakeSession::check('Auth')) { $this->_isAdmin = CakeSession::read('Auth.User.is_admin') ? true : false; } }
/** * Saves a new product credit * * @param int $market_id * @param int $presenter_sequence_id The presenter sequence id * @param int $credit_type * @param decimal $amount * @param int $user_id * @return boolean */ public function saveCredit($market_id, $presenter_sequence_id, $credit_type, $amount, $user_id) { $entry_type_id = 2; $status_type_id = 2; $ref = CakeSession::read('admin_user')->id; $entry_user = '******'; //convert presenter sequence id to primary key id require_once APPLICATION_PATH . MODEL_DIR . '/Presenter.php'; $presenter = new Presenter(); $presenter_id = $presenter->getIdBySequenceId($presenter_sequence_id); $sql = "INSERT INTO {$this->_table_name} " . "(market_id, user_id, presenter_id, product_credit_type_id, product_credit_entry_type_id, product_credit_status_type_id, entry_user, created, reference_id, amount) " . "VALUES (:market, :user, :presenter, :type, :entry, :status, :entry_user, NOW(), :ref, :amt)"; $query = $this->_db->prepare($sql); $query->bindParam(':market', $market_id); $query->bindParam(':user', $user_id); $query->bindParam(':presenter', $presenter_id); $query->bindParam(':type', $credit_type); $query->bindParam(':entry', $entry_type_id); $query->bindParam(':status', $status_type_id); $query->bindParam(':ref', $ref); $query->bindParam(':entry_user', $entry_user); $query->bindParam(':amt', $amount); if ($query->execute()) { return TRUE; } }
/** * tearDown * * @return void */ public function tearDown() { Configure::write('Config.language', null); CakeSession::write('Auth.User', null); unset($this->Questionnaire); parent::tearDown(); }
function add() { $marketing_adv = $this->AdvertisingLink->find('list', array('fields' => 'id,description', 'conditions' => array('AdvertisingLink.marketing_channels_id' => (int) Configure::read('Settings.Company.DefaultChannel'), 'AdvertisingLink.history_status' => 1), 'recursive' => -1, 'permissionable' => false)); $this->set('files', array()); $this->set('advertisingLinks', $marketing_adv); $this->set('affiliates', $this->Affiliate->find('list', array('fields' => 'id,name', 'joins' => array(array('table' => 'users_groups', 'alias' => 'UsersGroup', 'type' => 'LEFT', 'conditions' => array('UsersGroup.user_id = Affiliate.id'))), 'conditions' => array('UsersGroup.group_id' => (int) Configure::read('Settings.Company.AffiliateGroupId'), 'Affiliate.active' => 1)))); if ($this->request->is('post') || $this->request->is('put')) { $this->request->data['Enquiry']['enq_date'] = sqlFormatDate($this->request->data['Enquiry']['enq_date']); $this->request->data['Enquiry']['enquiry_time'] = gmdate('Y-m-d H:i:s'); $this->Captcha = $this->Components->load('Captcha'); $this->Enquiry->setCaptcha($this->Captcha->getVerCode()); if (isset($this->request->data['Enquiry']['files'])) { $dataImage = $this->request->data['Enquiry']['files']; $this->request->data['Enquiry']['file_list'] = json_encode($dataImage); } else { $this->request->data['Enquiry']['file_list'] = null; } $this->Enquiry->create(); $this->request->data['Enquiry']['agent_id'] = CakeSession::read("Auth.User.id"); //print_r( $this->request->data );die; if ($this->Enquiry->save($this->request->data)) { $this->Session->setFlash(__('Enquiry has been saved')); return $this->redirect(array('action' => 'index')); } } $this->render('edit'); }
public function exitSystem() { session_start(); session_destroy(); CakeSession::destroy(); $this->redirect('/logins/index', null, true); }
public function login($action = '/Tasks/index') { $this->layout = "user"; if ($this->request->isPost()) { $this->request->data['User']['email'] = trim($this->request->data['User']['email']); $this->request->data['User']['password'] = trim($this->request->data['User']['password']); $postData = $this->data; $email = $postData['User']['email']; $password = $postData['User']['password']; $this->User->recursive = -1; $this->User->cache = false; $user = $this->User->findByEmail($email); if ($user['User']['password'] == $password) { $this->UserAuth->login($user); $uri = $this->Session->read(UserAuthComponent::originAfterLogin); if ($user['User']['role'] == 'admin') { $action = "/admin/Users/index"; } if (!$uri) { $uri = $action; } CakeSession::delete('Message.flash'); $this->Session->delete(UserAuthComponent::originAfterLogin); $this->redirect($uri); } $this->User->validationErrors = array('password' => array("密码错误")); $this->warning('密码错误'); return; } }
/** * MISC **/ private function getUploadPath(Model $model, $path, $extension) { $path = trim($path, '/'); $replace = array(':id1000' => ceil($model->id / 1000), ':id100' => ceil($model->id / 100), ':id' => $model->id, ':y' => date('Y'), ':m' => date('m'), ':uid' => CakeSession::read('Auth.User.id'), ':md5' => md5(rand() . uniqid() . time())); $path = strtr($path, $replace) . '.' . $extension; return $path; }
/** * faved * * @return Mixed $id or false */ public function faved($key, $modelId) { if (empty($key) || empty($modelId)) { throw new FavException(__('Fav: Invalid Fav.keys.')); } $keys = Configure::read('Fav.keys'); if (!array_key_exists($key, $keys) || !array_key_exists('model', $keys[$key]) || !array_key_exists('type', $keys[$key])) { throw new FavException(__('Fav: Invalid Fav.keys.')); } $sessionKey = 'Auth.User.id'; if (array_key_exists('userIdSessionKey', $keys[$key])) { $sessionKey = $keys[$key]['userIdSessionKey']; } $userId = CakeSession::read($sessionKey); if (empty($userId)) { throw new FavException(__('Fav: User not found')); } $userModel = 'User'; if (array_key_exists('userModel', $keys[$key])) { $userModel = $keys[$key]['userModel']; } $type = $keys[$key]['type']; $model = $keys[$key]['model']; $data = array('type' => $type, 'user_model' => $userModel, 'user_id' => $userId, 'model' => $model, 'model_id' => $modelId); $fav = $this->find('first', array('conditions' => $data)); if (empty($fav)) { return false; } return $fav['Fav']['id']; }
public function login() { if (isset($this->Controller->request->query['code'])) { $code = $this->Controller->request->query['code']; } if (isset($this->Controller->request->query['state'])) { $state_request = $this->Controller->request->query['state']; } if (empty($code)) { CakeSession::write('state', md5(uniqid(rand(), TRUE))); $state_session = CakeSession::read('state'); // CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->app_id . "&redirect_uri=" . urlencode($this->my_url) . "&state=" . $state_session . "&scope=email"; $this->__redirectFunc($dialog_url); } if (CakeSession::read('state') && CakeSession::read('state') === $state_request) { $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $this->app_id . "&redirect_uri=" . urlencode($this->my_url) . "&client_secret=" . $this->app_secret . "&code=" . $code; $response = file_get_contents($token_url); parse_str($response, $params); CakeSession::write('access_token', $params['access_token']); $graph_url = "https://graph.facebook.com/me?access_token=" . CakeSession::read('access_token'); $user = json_decode(file_get_contents($graph_url)); return $user; } else { echo "The state does not match. You may be a victim of CSRF."; } }
function beforeFilter() { if (!CakeSession::started()) { CakeSession::start(); } $this->Auth->allow(); }
public function postLogin() { $this->loadModel('User'); $key = 'iznWsaal5lKhOKu4f7f0YagKW81ClEBXqVuTjrFovrXXtOggrqHdDJqkGXsQpHf'; $email = trim($this->request->data['email']); $password = trim($this->request->data['password']); $encrypted_password = Security::cipher($password, $key); $opts = array('conditions' => array('and' => array('User.user_email' => $email, 'User.password' => $encrypted_password))); $userInfo = $this->User->find('first', $opts); if ($userInfo) { //session CakeSession::write('session_id', $userInfo['User']['user_id']); CakeSession::write('session_name', $userInfo['User']['user_name']); CakeSession::write('session_email', $userInfo['User']['user_email']); $this->redirect('../User/user_profile'); } else { $this->loadModel('CreateGroup'); $opts = array('conditions' => array('and' => array('CreateGroup.group_admin_email' => $email, 'CreateGroup.password' => $encrypted_password))); $groupInfo = $this->CreateGroup->find('first', $opts); if ($groupInfo) { //session CakeSession::write('session_id', $groupInfo['CreateGroup']['group_id']); CakeSession::write('session_name', $groupInfo['CreateGroup']['group_name']); CakeSession::write('session_code', $groupInfo['CreateGroup']['group_code']); CakeSession::write('session_email', $groupInfo['CreateGroup']['group_admin_email']); $this->redirect('../Admin/group_profile'); } else { $this->Session->write('login_message', 'Invalid username or password'); $this->redirect('../login/home'); } } }
protected function _fileManager() { if (CakeSession::read('Auth.User') && defined('WWW_ROOT')) { } else { return null; } }
/** * Locking rows. * * After a row has been pulled from the database this will record the locked * state with the user that locked it. if a user reads a row that they * locked the date will be updated. if a different user tries to read this * row nothing will be retured and the component will take over displaying * an error message * * @var object $Model the current model * @var array $results the data that was found * @var bool $primary is it the main model doing the find */ public function afterFind($Model, $results, $primary) { $this->userId = class_exists('CakeSession') ? CakeSession::read('Auth.User.id') : null; if (!$this->userId || $Model->findQueryType != 'first' || !$primary || empty($results)) { if (!$this->userId || $Model->findQueryType != 'all') { return $results; } foreach ($results as $k => &$result) { $result['Lock']['Locker'] = $result['LockLocker']; unset($result['LockLocker']); } return $results; } if (isset($results[0][$Model->alias][$Model->primaryKey])) { $Lock = ClassRegistry::init('Locks.Lock'); $lock = $Lock->find('all', array('conditions' => array('Lock.foreign_key' => $results[0][$Model->alias][$Model->primaryKey], 'Lock.class' => $Model->fullModelName()), 'contain' => array('Locker'))); if (isset($lock[0]['Lock']['user_id']) && $this->userId == $lock[0]['Lock']['user_id']) { $Lock->delete($lock[0]['Lock']['id']); $lock = array(); } if (!empty($lock)) { return $lock; } $lock['Lock'] = array('foreign_key' => $results[0][$Model->alias][$Model->primaryKey], 'class' => $Model->fullModelName(), 'user_id' => $this->userId); $Lock->create(); $Lock->save($lock); } return $results; }
protected function _getSite($siteId = null) { $Site = ClassRegistry::init('Sites.Site'); $SiteDomain = $Site->SiteDomain; $SiteMeta = $Site->SiteMeta; $siteDomainTable = $SiteDomain->getDataSource()->fullTableName($SiteDomain, true, true); $siteMetaTable = $Site->SiteMeta->getDataSource()->fullTableName($SiteMeta, true, true); $options = array('recursive' => false, 'fields' => array('Site.id', 'Site.title', 'Site.tagline', 'Site.theme', 'Site.timezone', 'Site.locale', 'Site.status', 'SiteMeta.robots', 'SiteMeta.keywords', 'SiteMeta.description'), 'joins' => array(array('table' => $siteDomainTable, 'alias' => 'SiteDomain', 'conditions' => array('SiteDomain.site_id = Site.id'))), array('table' => $siteMetaTable, 'alias' => 'SiteMeta', 'conditions' => array('SiteMeta.site_id = Site.id'))); $host = env('HTTP_HOST'); if (empty($siteId)) { $options['joins'][0]['conditions']['SiteDomain.domain LIKE'] = '%' . $host; $options['cache'] = array('name' => 'sites_' . $host, 'config' => 'sites'); } else { $options['conditions'] = array('Site.id' => $siteId); $options['cache'] = array('name' => 'sites_' . $siteId, 'config' => 'sites'); } $site = $Site->find('first', $options); if (empty($site)) { $site = $Site->find('first', array('recursive' => false, 'fields' => array('id', 'title', 'tagline', 'theme', 'timezone', 'locale', 'status'), 'joins' => array(array('table' => $siteDomainTable, 'alias' => 'SiteDomain', 'conditions' => array('SiteDomain.site_id = Site.id'))), array('table' => $siteMetaTable, 'alias' => 'SiteMeta', 'conditions' => array('SiteMeta.site_id = Site.id')), 'conditions' => array('Site.default' => 1))); } if ($siteId === null && CakeSession::check(self::$_sessionKey) && ($active = CakeSession::read(self::$_sessionKey))) { $found = $SiteDomain->find('count', array('cache' => array('name' => 'sites_count_' . $host, 'config' => 'sites'), 'conditions' => array('SiteDomain.domain' => $host))); if ($found == 0) { $site = $active; } } return $site; }
/** * Fill the created_by and updated_by fields * * Note: Since shells do not have Sessions, created_by/updated_by fields * will not be populated. If a shell needs to populate these fields, you * can simulate a logged in user by setting `Trackable.Auth` config: * * Configure::write('Trackable.User', array('id' => 1)); * * Note that value stored in this variable overrides session data. */ public function beforeSave(Model $model, $options = array()) { if (!$this->_hasTrackableFields($model)) { return true; } $config = $this->settings[$model->alias]; $User = ClassRegistry::init($config['userModel']); $userAlias = $User->alias; $userPk = $User->primaryKey; $user = Configure::read('Trackable.Auth.User'); if (!$user && CakeSession::started()) { $user = AuthComponent::user(); } if ($user && array_key_exists($userPk, $user)) { $userId = $user[$userPk]; } if (empty($user) || empty($userId)) { return true; } $alias = $model->alias; $createdByField = $config['fields']['created_by']; $updatedByField = $config['fields']['updated_by']; if (empty($model->data[$alias][$createdByField])) { if (!$model->exists()) { $model->data[$alias][$createdByField] = $user[$userPk]; } } $model->data[$alias][$updatedByField] = $userId; if (!empty($model->whitelist)) { $model->whitelist[] = $createdByField; $model->whitelist[] = $updatedByField; } return true; }
/** * 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; }
/** * Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields` * to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if * there is no post data, either username or password is missing, of if the scope conditions have not been met. * * @param CakeRequest $request The request that contains login information. * @param CakeResponse $response Unused response object. * @return mixed. False on login failure. An array of User data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { $userModel = $this->settings['userModel']; list($plugin, $model) = pluginSplit($userModel); if (empty($request->data[$model])) { return false; } if (empty($request->data[$model][$this->settings['post_key']]) || empty($request->data[$model][$this->settings['fields']['password']])) { return false; } $User = ClassRegistry::init($userModel); $password = $request->data[$model][$this->settings['fields']['password']]; foreach ($this->settings['fields']['username'] as $username) { $conditions = array(); if (!empty($this->settings['scope'])) { $conditions = array_merge($conditions, $this->settings['scope']); } $conditions[$model . '.' . $username] = $request->data[$model][$this->settings['post_key']]; $conditions[$model . '.' . $this->settings['fields']['password']] = $this->_password($password); $result = $User->find('first', array('conditions' => $conditions, 'contain' => $this->settings['contain'])); if (!empty($result) || !empty($result[$model])) { CakeSession::write(Configure::read('SessionKey'), $result); unset($result[$model][$this->settings['fields']['password']]); return $result[$model]; } } return false; }