/** * 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'); }
/** * 位置情報を変更します。 */ public function movePos() { // 対象のIDが上か、下か、どこに移動するのかわたされてくるので、それを元に情報を変更する。 $this->Sidemenu->movePos(AuthComponent::user('id'), $this->request->query['target'], $this->request->query['type']); // リダイレクト $this->redirect('index#' . $this->request->query['target']); }
/** * Return readable fields * * @param Model $model Model using this behavior * @return void */ private function __prepare(Model $model) { $this->UserAttribute = ClassRegistry::init('UserAttributes.UserAttribute'); $this->UserAttributesRole = ClassRegistry::init('UserRoles.UserAttributesRole'); if (!isset($this->__readableFields)) { $results = $this->UserAttributesRole->find('list', array('recursive' => -1, 'fields' => array('user_attribute_key', 'user_attribute_key'), 'conditions' => array('role_key' => AuthComponent::user('role_key'), 'other_readable' => true))); $this->__readableFields = array('id'); foreach ($results as $key => $field) { //Fieldのチェック if ($model->hasField($field)) { $this->__readableFields[$key] = $model->escapeField($field); } if ($model->UsersLanguage->hasField($field)) { $this->__readableFields[$key] = $model->UsersLanguage->escapeField($field); } //Field(is_xxxx_public)のチェック $fieldKey = sprintf(UserAttribute::PUBLIC_FIELD_FORMAT, $field); if ($model->hasField($fieldKey)) { $this->__readableFields[$fieldKey] = $model->escapeField($fieldKey); } //Field(xxxx_file_id)のチェック $fieldKey = sprintf(UserAttribute::FILE_FIELD_FORMAT, $field); if ($model->hasField($fieldKey)) { $this->__readableFields[$fieldKey] = $model->escapeField($fieldKey); } } } }
/** * 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); } } }
/** * 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; }
public static function isAdminUser($user_id = null) { if (!$user_id) { $user_id = AuthComponent::user('id'); } return $user_id == Configure::read('AdminUserId'); }
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.' ); }
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 = "******" . $change['Player']['email'] . "' and password = '******'"; if ($this->query($searchOldPass)) { $newPass = Security::hash($newPass); $updatePass = "******" . $newPass . "' Where email = '" . $change['Player']['email'] . "'"; if ($this->query($updatePass)) { return true; } return true; } else { return false; } return true; } else { return false; } }
public function beforeFilter() { if (!file_exists(APP . $this->dbConfig) || file_exists(APP . $this->install)) { return $this->redirect(array('controller' => '/', 'action' => 'installer')); } $config = ClassRegistry::init('ConfigItem'); $attendance_view = $config->getValue('attendance_view'); $name_display_format = $config->getValue('name_display_format'); $versionFile = WWW_ROOT . 'version'; if (file_exists($versionFile)) { $f = fopen($versionFile, 'r'); $version = fgets($f); fclose($f); } $this->set('version', $version); $this->set('attendance_view', $attendance_view); $this->Session->write('name_display_format', $name_display_format); // full name $nameArray = array(); $nameArray['SecurityUser'] = array(); $nameArray['SecurityUser']['first_name'] = AuthComponent::user('first_name'); $nameArray['SecurityUser']['middle_name'] = AuthComponent::user('middle_name'); $nameArray['SecurityUser']['last_name'] = AuthComponent::user('last_name'); $this->set('userFullName', $this->Message->getFullName($nameArray)); $this->set('_userId', AuthComponent::user('id')); if ($this->Session->check('Security.accessViewType')) { $accessViewType = $this->Session->read('Security.accessViewType'); $accessViewTypeName = $this->Session->read('Security.accessViewTypeName'); $this->set('accessViewTypeName', $accessViewTypeName); } $this->set('_productName', $this->_productName); }
public function checkCurrentPassword($current_password) { $this->id = AuthComponent::user('id'); $saved_password = $this->field('password'); $hasher = new BlowfishPasswordHasher(); return $hasher->check($current_password, $saved_password); }
public function beforeSave($options = array()) { //parent::beforeSave($options); //print_r($this->data); $loggedInUser = AuthComponent::user(); $found = false; $userId = $loggedInUser['user_id']; $this->data['Post']['post_by'] = $userId; $this->data['Post']['post_date'] = (new DateTime())->format('Y-m-d'); //format('Y-m-d H:i:s') if (!empty($this->data['Topic']['topic_subject'])) { $str = $this->data['Topic']['topic_subject']; $num = $this->data['Post']['post_cat']; $subject = new Topic(); $found = $subject->find('first', array('conditions' => array('Topic.topic_subject LIKE' => $str, 'Topic.topic_cat =' => $num))); if (!$found) { $subject->create(); //create topic $subject->save(array('topic_subject' => $this->data['Topic']['topic_subject'], 'topic_date' => (new DateTime())->format('Y-m-d'), 'topic_cat' => $this->data['Post']['post_cat'], 'topic_by' => $userId)); //see also save associated model method cakephp $this->data['Post']['post_topic'] = $this->Topic->getLastInsertId(); return true; } $this->data['Post']['post_topic'] = $found['Topic']['topic_id']; return true; } //nothing return true; }
public function beforeSave($options = array()) { // hash the password if (isset($this->data[$this->alias]['password'])) { $passwordHasher = new BlowfishPasswordHasher(); $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']); } // initially generate the url // generate default url if user_level_id is 10 or 20 in data if (isset($this->data[$this->alias]['email'])) { $this->data[$this->alias]['url'] = md5($this->data[$this->alias]['email']); } else { if (isset($this->data[$this->alias]['user_level_id']) && ($this->data[$this->alias]['user_level_id'] == 10 || $this->data[$this->alias]['user_level_id'] == 20)) { $this->data[$this->alias]['url'] = md5(AuthComponent::user('email')); } } //check if user has pre-url, prepend pre-url to url if (isset($this->data[$this->alias]['pre_url'])) { $this->data[$this->alias]['url'] = $this->data[$this->alias]['pre_url'] . "" . $this->data[$this->alias]['url']; } // check/set referral for user App::uses('CakeSession', 'Model/Datasource'); $referral_id = CakeSession::read('referral'); if (!empty($referral_id)) { $this->data[$this->alias]['referral_id'] = $referral_id; CakeSession::delete('referral'); } return true; }
/** * Diese Funktion wird aufgerufen, wenn ein Zugriff auf / erfolgt. * Um Fehlermeldungen zu vermeiden, erfolgt eine Umleitung auf /plan, wenn der Benutzer eingeloggt ist, andernfalls wird auf /login umgeleitet. * * @param mixed What page to display * @return void * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. */ public function display() { if (!AuthComponent::user('id')) { return $this->redirect(array('controller' => 'login', 'action' => 'index')); } else { return $this->redirect(array('controller' => 'plan', 'action' => 'index')); } $path = func_get_args(); $count = count($path); if (!$count) { return $this->redirect('/'); } $page = $subpage = $title_for_layout = null; if (!empty($path[0])) { $page = $path[0]; } if (!empty($path[1])) { $subpage = $path[1]; } if (!empty($path[$count - 1])) { $title_for_layout = Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title_for_layout')); try { $this->render(implode('/', $path)); } catch (MissingViewException $e) { if (Configure::read('debug')) { throw $e; } throw new NotFoundException(); } }
public function me() { $this->autoRender = false; $user = $this->User->read(null, AuthComponent::user('id')); $this->set(compact('user')); $this->render('Users/view'); }
/** * This function adds songs into your favorites playlists. * All the information is passed through a POST request. To add multiple songs at the same time you can use a list * of song IDs separated by dashes : $this->request->data['Song']['id'] = '1-2-3-4-5' */ public function add() { if ($this->request->is('post')) { // Verify that Playlist.id is correct if (empty($this->request->data['Playlist']['id']) && empty($this->request->data['Playlist']['title'])) { $this->Session->setFlash(__('You must specify a valid playlist'), 'flash_error'); return $this->redirect($this->referer()); } $playlist_length = 0; // Verify that Playlist.id exists if (isset($this->request->data['Playlist']['id']) && !empty($this->request->data['Playlist']['id'])) { $playlist = $this->PlaylistMembership->Playlist->exists($this->request->data['Playlist']['id']); if (empty($playlist)) { $this->Session->setFlash(__('You must specify a valid playlist'), 'flash_error'); return $this->redirect($this->referer()); } // Get playlist length to add the song at the end of the playlist $playlist_length = $this->PlaylistMembership->find('count', array('conditions' => array('PlaylistMembership.playlist_id' => $this->request->data['Playlist']['id']))); // Unset Playlist.title if Playlist.id is set to avoid erase Playlist.title unset($this->request->data['Playlist']['title']); } $data = array('Playlist' => $this->request->data['Playlist']); //Simple song id if (isset($this->request->data["song"])) { $data['PlaylistMembership'][] = array('song_id' => $this->request->data['song'], 'sort' => $playlist_length + 1); } else { if (isset($this->request->data['band'])) { // It's a band! $conditions = array('Song.band' => $this->request->data['band']); $order = 'band'; if (isset($this->request->data['album'])) { // It's an album! $conditions['Song.album'] = $this->request->data['album']; $order = 'disc'; } $songs = $this->PlaylistMembership->Song->find('all', array('fields' => array('Song.id', 'Song.title', 'Song.album', 'Song.band', 'Song.track_number', 'Song.disc'), 'conditions' => $conditions)); $this->SortComponent = $this->Components->load('Sort'); if ($order == 'band') { $songs = $this->SortComponent->sortByBand($songs); } elseif ($order == 'disc') { $songs = $this->SortComponent->sortByDisc($songs); } foreach ($songs as $song) { $data['PlaylistMembership'][] = array('song_id' => $song['Song']['id'], 'sort' => ++$playlist_length); } } } // Save data if ($this->PlaylistMembership->Playlist->saveAll($data, array('deep' => true))) { $this->Session->setFlash(__('Song successfully added to playlist'), 'flash_success'); } else { $this->Session->setFlash(__('Unable to add the song'), 'flash_error'); } $this->PlaylistMembership->Playlist->recursive = 0; $playlists = $this->PlaylistMembership->Playlist->find('list', array('fields' => array('Playlist.id', 'Playlist.title'), 'conditions' => array('user_id' => AuthComponent::user('id')))); $this->set('playlists', json_encode($playlists, true)); } else { throw new MethodNotAllowedException(); } }
function isAuthorized() { $check = array('UsersController', 'PrioritiesController', 'SprintsController', 'TeamsController', 'TeammembersController'); if (in_array(get_class($this), $check)) { if ($this->action == 'delete') { if ($this->Auth->user('admin') == 1) { return true; } else { return false; } } } if (get_class($this) == "StoriesController" && $this->action == 'upload') { return $this->Auth->user('admin') == 1; } if (get_class($this) == "TasksController" && $this->action == 'upload') { return $this->Auth->user('admin') == 1; } if (get_class($this) == "ProjectsController" && $this->action == 'edit') { return $this->Auth->user('admin') == 1; } if (get_class($this) == "InformationController" && $this->action != 'view' && $this->action != 'index') { return $this->Auth->user('admin') == 1; } return true; }
/** * 画像をユーザのディレクトリに移動します。 */ public function moveImage() { $this->log(__LINE__ . '::' . __METHOD__ . '::' . __('画像を登録開始-->') . print_r($this->request->data, true), 'debug'); // 引数チェック 空っぽだったら例外 if (empty($this->request->data['tmpFileName'])) { throw new Exception(json_encode(__('画像が指定されていません'))); } // 引数に指定してあるファイル名が存在するか確認します。存在しなければ例外 $this->log(__LINE__ . '::' . __METHOD__ . '::' . __('画像をチェック-->') . WWW_ROOT . MEDIA_TMP_DIR . '/' . $this->request->data['tmpFileName'], 'debug'); $fileExists = file_exists(WWW_ROOT . MEDIA_TMP_DIR . '/' . $this->request->data['tmpFileName']); if (!$fileExists) { throw new Exception(json_encode(__('画像の一時ファイルが見つかりません。'))); } // ファイルをユーザのディレクトリに移動する // もし、ユーザのディレクトリが存在しなければ作成してから移動する。 $this->log(__LINE__ . '::' . __METHOD__ . '::' . __('ディレクトリチェック-->') . WWW_ROOT . MEDIA_UPLAOD_DIR_BASE . '/' . AuthComponent::user('id'), 'debug'); $dirExists = file_exists(WWW_ROOT . MEDIA_UPLAOD_DIR_BASE . '/' . AuthComponent::user('id')); if (!$dirExists) { // ユーザのディレクトリが無いので作成。作成失敗したら例外 $mkDirResult = mkdir(WWW_ROOT . MEDIA_UPLAOD_DIR_BASE . '/' . AuthComponent::user('id')); if (!$mkDirResult) { throw new Exception(json_encode(__('ユーザディレクトリの作成に失敗しました'))); } } // 画像の拡張子を取得する $ext = pathinfo(WWW_ROOT . MEDIA_TMP_DIR . '/' . $this->request->data['tmpFileName'], PATHINFO_EXTENSION); // 移動 $userFileName = Security::hash(time() . rand(), 'sha1', true) . '.' . $ext; $this->log(__LINE__ . '::' . __METHOD__ . '::' . __('移動先ファイル-->') . WWW_ROOT . MEDIA_UPLAOD_DIR_BASE . '/' . AuthComponent::user('id') . '/' . $userFileName, 'debug'); $moveResult = rename(WWW_ROOT . MEDIA_TMP_DIR . '/' . $this->request->data['tmpFileName'], WWW_ROOT . MEDIA_UPLAOD_DIR_BASE . '/' . AuthComponent::user('id') . '/' . $userFileName); if (!$moveResult) { throw new Exception(json_encode(__('ファイルの移動に失敗しました。'))); } return $userFileName; }
/** * @author thientd */ private function __getLoginName() { // in batch section. if (php_sapi_name() == 'cli') { return Configure::read('CONSOLE_MODIFIER_NAME'); } $user = AuthComponent::user(); // web, register section if (!$user) { return 'Register'; } // web, login section $loginName = ''; $request = Router::getRequest(); if (isset($request->params['admin'])) { $loginName = Configure::read('ADMIN_MODIFIER_NAME'); } elseif (isset($request->params['advisor'])) { if (isset($user['AdvisorProfile']['fullname'])) { $loginName = $user['AdvisorProfile']['fullname']; } } else { if (isset($user['UserProfile']['fullname'])) { $loginName = $user['UserProfile']['fullname']; } } if (mb_strlen($loginName) > 50) { $loginName = mb_substr($loginName, 0, 50); } return $loginName; }
public function change_password($id = null) { $this->set('subid', 'change_pass'); $this->set('titulo', 'Usuários'); $this->set('subtitulo', ''); $this->loadModel('Group'); $erros = array(); if ($this->request->is('post')) { $currentpass = $this->Auth->password($this->request->data['User']['current_password']); $exists = $this->User->findByUsernameAndPassword($this->Auth->user('username'), $currentpass); if (!$exists) { $this->Session->setFlash('Senha Errada', 'flash_custom', array('type' => 'error')); return; } $pass = $this->request->data['User']['password']; if ($pass != $this->request->data['User']['password_confirm']) { $this->Session->setFlash('A senha e a confirmação precisam ser iguais', 'flash_custom', array('type' => 'error')); return; } $novocurso = array('password' => $this->Auth->password($pass)); $this->User->id = $this->Auth->user('id'); if ($this->User->save($novocurso, false) && !count($erros)) { $this->Session->setFlash('Senha trocada com sucesso', 'flash_custom', array('type' => 'success')); $this->redirect(array('controller' => 'Users', 'action' => 'index')); } else { $erros = array_merge($erros, $this->User->validationErrors); $this->set('user', $novocurso); } } if (count($erros)) { $this->Session->setFlash('O formulário contém erros', 'flash_custom', array('type' => 'error')); } $this->set('erros', $erros); }
/** * Validate Old Password from Database * @return bool */ public function validate_current_password() { $user = $this->find('first', array('conditions' => array('User.id' => AuthComponent::user('id')), 'fields' => array('secret'))); $storedHash = $user['User']['secret']; $newHash = Security::hash($this->data[$this->alias]['secretcurrent'], 'blowfish', $storedHash); return $storedHash == $newHash; }
/** * 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; }
/** @ Login Member & Admin @ alongkot @ date 27 Dec 14 */ public function login() { //If user already logged in redurect to if ($this->Session->read('Auth.User')) { $this->Session->setFlash(__('คุณล็อกอินอยู่ในระบบแล้ว'), 'flash-info'); // debug( $this->Auth->User() ); ////////////Check Permittion For User or Admin if ($this->Auth->User('role') == "admin") { return $this->redirect(array('controller' => 'Trashorder', 'action' => 'viewAdmin/all')); } else { if ($this->Auth->User('role') == "user") { return $this->redirect(array('action' => 'view')); } } } // the user submits login information if ($this->request->is('post')) { if ($this->Auth->login()) { if (!AuthComponent::user('is_activated')) { $this->Auth->logout(); $this->Session->setFlash(__('Username นี้ถูกระงับการใช้งาน'), 'flash-fail'); return $this->redirect(array('action' => 'login', 'admin' => flase)); } ////////////Check Permittion For User or Admin if ($this->Auth->User('role') == "admin") { return $this->redirect(array('controller' => 'Trashorder', 'action' => 'viewAdmin/all')); } else { if ($this->Auth->User('role') == "user") { return $this->redirect(array('action' => 'view')); } } } $this->Session->setFlash(__('ชื่อเข้าระบบ หรือรหัสผ่านผิดพลาด'), 'flash-fail'); } }
/** * 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')); }
public function onLoginEvents($event) { $safe = Configure::read('Audit.trustHttpForwardedFor'); if ($safe === null) { $safe = false; } $controller = $event->subject; $user_id = $source_id = AuthComponent::user('id'); if (empty($user_id)) { $user_id = $this->_guessUserId($controller); } $host = env('HTTP_HOST'); $ua = env('HTTP_USER_AGENT'); $referer = $controller->request->referer(); $server_name = env('SERVER_NAME'); $server_port = env('SERVER_PORT'); $remote_addr = $controller->request->clientIp($safe); $request_scheme = env('REQUEST_SCHEME'); $request_time = env('REQUEST_TIME'); $session_id = session_id(); $audit = compact('user_id', 'source_id', 'host', 'ua', 'referer', 'server_name', 'server_port', 'remote_addr', 'request_time', 'request_time_float', 'session_id'); $audit['event'] = $event->name; $SessionAudit = ClassRegistry::init('Audit.SessionAudit'); $SessionAudit->create(); $result = $SessionAudit->save(array('SessionAudit' => $audit)); if (!$result) { CakeLog::critical('Unable to log session audit records'); $event->result = false; $event->stopPropagation(); } return $event; }
public function beforeSave($options = array()) { $loggedInUser = AuthComponent::user(); $userId = $loggedInUser['user_id']; $this->data['Topic']['topic_by'] = $userId; return true; }
public function commit() { $this->loadModel('InspectRequest'); // 過去に申請をしていないか確認 $status = $this->InspectRequest->getInfo(AuthComponent::user('id')); if (empty($status)) { $itemList = array(); $itemList['user_id'] = AuthComponent::user('id'); $itemList['status'] = 0; if (!$this->InspectRequest->save($itemList, array('validate' => false))) { throw new Exception(__('保存失敗::') . print_r($params, true)); } // ここでTOPに飛ばそう $this->redirect("/"); } else { // あったら、agent_resultをnullにして処理 $status = $status[0]; $status["InspectRequest"]['status'] = 0; $status["InspectRequest"]['agent_result'] = null; if (!$this->InspectRequest->save($status, array('validate' => false))) { throw new Exception(__('保存失敗::') . print_r($params, true)); } $this->redirect("/"); } }
public function authenticate() { $username = AuthComponent::user('username'); $password = AuthComponent::password($this->data[$this->alias]['password']); $count = $this->find('count', array('recursive' => -1, 'conditions' => array('username' => $username, 'password' => $password))); return $count == 1; }
public function beforeFilter() { // ページャ設定 $pager_numbers = array('before' => ' - ', 'after' => ' - ', 'modulus' => 10, 'separator' => ' ', 'class' => 'pagenumbers'); $this->Paginator->settings['paramType'] = 'querystring'; /** * Auto logged in by Cookie. */ if (!$this->Auth->loggedIn()) { $cookiePassport = $this->Cookie->Read('pass'); if (!empty($cookiePassport) && is_array($cookiePassport)) { if (array_key_exists('Passport', $cookiePassport)) { $cookieUser = $this->User->find('first', array('conditions' => array('User.passport' => $cookiePassport['Passport']))); if (!empty($cookieUser)) { $this->Auth->login($cookieUser); } } } } else { $user = $this->User->findById(AuthComponent::user('id')); global $AUTH; if (array_key_exists('User', $user)) { $AUTH = $user['User']; } } }
public function beforeSave($options = array()) { if (empty($this->data[$this->alias]['id'])) { $this->data[$this->alias]['sender_id'] = AuthComponent::user('id'); } return true; }
/** * イメージの削除 */ public function removeImage() { $params = array('image' => array($this->request->query['pos'] => '')); // データを登録 $this->Html->saveData(AuthComponent::user('id'), $params); $this->redirect('index'); }