/** * undocumented function * * @param unknown $key * @param unknown $userId * @return void * @access public */ static function verify($key, $user_id, $auth_key_type_id, $foreign_id = null) { $_this = ClassRegistry::init('AuthKey'); AuthKey::purgeExpired(); if (!Common::isUuid($auth_key_type_id)) { $auth_key_type_id = $_this->AuthKeyType->lookup($auth_key_type_id, 'id', false); } if (!Common::isUuid($auth_key_type_id)) { return false; } $options = compact('key', 'user_id', 'auth_key_type_id'); if (!empty($foreign_id)) { $options = compact('key', 'user_id', 'auth_key_type_id', 'foreign_id'); } return $_this->hasAny($options); }
/** * undocumented function * * @return void * @access public */ function view($key) { $userId = $this->params['named']['user_id']; $authKeyTypeId = $this->params['named']['auth_key_type_id']; Assert::true(Common::isUuid($userId), '403'); Assert::true(Common::isUuid($authKeyTypeId), '403'); Assert::true(AuthKey::verify($key, $userId, $authKeyTypeId), '403'); $authKeyType = $this->AuthKey->AuthKeyType->lookup(array('id' => $authKeyTypeId), 'name', false); User::login($userId); switch ($authKeyType) { case 'Lost Password': $this->Session->write('lost_password', true); $msg = __('Please go ahead and change your password now.', true); $this->Message->add($msg, 'ok', true, '/admin/users/edit_password/' . $userId); } }
/** * undocumented function * * @param string $authKey * @return void * @access public */ function _addAuthkeyToSession($tId) { App::import('Model', 'TimeZone'); $userId = !User::is('guest') ? User::get('id') : $this->data['Contact']['email']; $authKeyTypeId = $this->AuthKeyType->lookup(array('name' => 'Transaction Receipt'), 'id', false); $authKey = AuthKey::generate(array('user_id' => $userId, 'auth_key_type_id' => $authKeyTypeId, 'foreign_id' => $tId, 'expires' => date('Y-m-d H:i:s', strtotime('+3 days')))); $keyData = array('user_id' => $userId, 'key' => $authKey, 'auth_key_type_id' => $authKeyTypeId, 'foreign_id' => $tId); $sessKey = 'gift_auth_keys'; $authKeys = $this->Session->read($sessKey); $authKeys[] = $keyData; $this->Session->write($sessKey, $authKeys); return $keyData; }
/** * undocumented function * * @return void * @access public */ static function cookieLogin() { $Cookie = Common::getComponent('Cookie'); $key = $Cookie->read('Auth.key'); if (empty($key)) { return false; } $userId = AuthKey::findUserId($key, 'Login Cookie'); if (empty($userId)) { return false; } return User::login($userId, true); }