本文整理汇总了PHP中getAuthentication函数的典型用法代码示例。如果您正苦于以下问题:PHP getAuthentication函数的具体用法?PHP getAuthentication怎么用?PHP getAuthentication使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAuthentication函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view
public function view($type = null)
{
getAuthentication()->requireAuthentication();
$note = $this->notification->get($type);
if (empty($note)) {
return $this->notFound('No notifications found', null);
}
return $this->success('Notification', $note);
}
开发者ID:gg1977,项目名称:frontend,代码行数:9,代码来源:ApiNotificationController.php
示例2: view
/**
* Retrieve a single action
*
* @param string $id The ID of the action to be retrieved.
* @return string Standard JSON envelope
*/
public function view($id)
{
getAuthentication()->requireAuthentication(false);
$action = $this->action->view($id);
if ($action) {
return $this->success("Action {$id}", $action);
}
return $this->error("Could not retrieve action {$id}", false);
}
开发者ID:gg1977,项目名称:frontend,代码行数:15,代码来源:ApiActionController.php
示例3: subscribe
/**
* Subscribe to a topic (creates a webhook).
*
* @return void
*/
public function subscribe()
{
getAuthentication()->requireAuthentication();
$params = $_POST;
$params['verify'] = 'sync';
if (isset($params['callback']) && isset($params['mode']) && isset($params['topic'])) {
$urlParts = parse_url($params['callback']);
if (isset($urlParts['scheme']) && isset($urlParts['host'])) {
if (!isset($urlParts['port'])) {
$port = '';
}
if (!isset($urlParts['path'])) {
$path = '';
}
extract($urlParts);
$challenge = uniqid();
$queryParams = array();
if (isset($urlParts['query']) && !empty($urlParts['query'])) {
parse_str($urlParts['query'], $queryParams);
}
$queryParams['mode'] = $params['mode'];
$queryParams['topic'] = $params['topic'];
$queryParams['challenge'] = $challenge;
if (isset($params['verifyToken'])) {
$queryParams['verifyToken'] = $params['verifyToken'];
}
$queryString = '';
if (!empty($queryParams)) {
$queryString = sprintf('?%s', http_build_query($queryParams));
}
$url = sprintf('%s://%s%s%s%s', $scheme, $host, $port, $path, $queryString);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$handle = getCurl()->addCurl($ch);
// verify a 2xx response and that the body is equal to the challenge
if ($handle->code >= 200 && $handle->code < 300 && $handle->data == $challenge) {
$apiWebhook = $this->api->invoke('/webhook/create.json', EpiRoute::httpPost, array('_POST' => $params));
if ($apiWebhook['code'] === 200) {
header('HTTP/1.1 204 No Content');
getLogger()->info(sprintf('Webhook successfully created: %s', json_encode($params)));
return;
}
}
$message = sprintf('The verification call failed to meet requirements. Code: %d, Response: %s, Expected: %s, URL: %s', $handle->code, $handle->data, $challenge, $url);
getLogger()->warn($message);
} else {
$message = sprintf('Callback url was invalid: %s', $params['callback']);
getLogger()->warn($message);
}
} else {
$message = sprintf('Not all required parameters were passed in to webhook subscribe: %s', json_encode($params));
getLogger()->warn($message);
}
header('HTTP/1.1 400 Bad Request');
echo $message;
}
开发者ID:gg1977,项目名称:frontend,代码行数:61,代码来源:WebhookController.php
示例4: delete
public function delete($id)
{
getAuthentication()->requireAuthentication();
getAuthentication()->requireCrumb();
$res = $this->token->delete($id);
if ($res === false) {
return $this->error('Could not delete share token', false);
}
return $this->noContent('Successfully deleted share token', true);
}
开发者ID:gg1977,项目名称:frontend,代码行数:10,代码来源:ApiTokenController.php
示例5: list_
public function list_()
{
getAuthentication()->requireAuthentication();
$res = getDb()->getCredentials();
if ($res !== false) {
return $this->success('Oauth Credentials', $res);
} else {
return $this->error('Could not retrieve credentials', false);
}
}
开发者ID:gg1977,项目名称:frontend,代码行数:10,代码来源:ApiOAuthController.php
示例6: __construct
/**
* Call the parent constructor
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->photo = new Photo();
$this->theme->setTheme();
// defaults
if (stristr($_SERVER['REQUEST_URI'], '/manage/apps/callback') === false) {
getAuthentication()->requireAuthentication();
}
}
开发者ID:nicolargo,项目名称:frontend,代码行数:15,代码来源:ManageController.php
示例7: version
/**
* API to get versions of the source, filesystem and database
*
* @return string Standard JSON envelope
*/
public function version()
{
getAuthentication()->requireAuthentication();
$apiVersion = Request::getLatestApiVersion();
$systemVersion = getConfig()->get('site')->lastCodeVersion;
$databaseVersion = getDb()->version();
$databaseType = getDb()->identity();
$filesystemVersion = '0.0.0';
$filesystemType = getFs()->identity();
return $this->success('System versions', array('api' => $apiVersion, 'system' => $systemVersion, 'database' => $databaseVersion, 'databaseType' => $databaseType, 'filesystem' => $filesystemVersion, 'filesystemType' => $filesystemType));
}
开发者ID:gg1977,项目名称:frontend,代码行数:16,代码来源:ApiController.php
示例8: purge
public function purge()
{
getAuthentication()->requireAuthentication();
getAuthentication()->requireCrumb();
$status = $this->activity->purge();
if ($status !== false) {
return $this->success('Purged user activities', true);
} else {
return $this->error('Purged user activities', false);
}
}
开发者ID:gg1977,项目名称:frontend,代码行数:11,代码来源:ApiActivityController.php
示例9: routeHandler
public function routeHandler($route)
{
parent::routeHandler($route);
switch ($route) {
case '/update.json':
getAuthentication()->requireAuthentication();
$user = new User();
$user->setAttribute($_POST['section'], $_POST['key']);
return array('message' => sprintf('Updated tutorial for %s', $_POST['section']), 'code' => 200, 'result' => true);
break;
}
}
开发者ID:gg1977,项目名称:frontend,代码行数:12,代码来源:TutorialPlugin.php
示例10: postGroup
/**
* Update a group
*
* @param string $id id of the group to update
* @return string Standard JSON envelope
*/
public function postGroup($id = null)
{
getAuthentication()->requireAuthentication();
if (!$id) {
$id = $this->user->getNextId('group');
}
$res = getDb()->postGroup($id, $_POST);
if ($res) {
return $this->success("Group {$id} was updated", array_merge(array('id' => $id), $_POST));
} else {
return $this->error("Could not updated group {$id}", false);
}
}
开发者ID:nicolargo,项目名称:frontend,代码行数:19,代码来源:ApiUserController.php
示例11: create
public function create()
{
getAuthentication()->requireAuthentication();
$id = $this->resourceMap->create($_POST);
if (!$id) {
return $this->error('Could not generate resource map.', false);
}
$resourceResp = $this->api->invoke("/s/{$id}/view.json");
if ($resourceResp['code'] !== 200) {
return $this->error('Could not retrieve resource map after creating it', false);
}
return $this->created("Resource map {$id} successfully created", $resourceResp['result']);
}
开发者ID:gg1977,项目名称:frontend,代码行数:13,代码来源:ApiResourceMapController.php
示例12: update
/**
* Update a tag in the tag database.
*
* @return string Standard JSON envelope
*/
public function update($tag)
{
getAuthentication()->requireAuthentication();
$tag = Tag::sanitize($tag);
$params = Tag::validateParams($_POST);
$res = getDb()->postTag($tag, $params);
if ($res) {
$tag = $this->api->invoke("/{$this->apiVersion}/tag/{$tag}/view.json", EpiRoute::httpGet);
return $this->success('Tag created/updated successfully', $tag['result']);
} else {
return $this->error('Tag could not be created/updated', false);
}
}
开发者ID:nicolargo,项目名称:frontend,代码行数:18,代码来源:ApiTagController.php
示例13: create
public function create($attributes)
{
getAuthentication()->requireAuthentication();
$attributes = array_merge($this->getDefaultAttributes(), $attributes);
$attributes = $this->whitelistParams($attributes);
if (!$this->validateParams($attributes)) {
$this->logger->warn('Not all required paramaters were passed to create an activity');
return false;
}
$id = $this->user->getNextId('activity');
if ($id === false) {
$this->logger->warn('Could not fetch the next activity id');
return false;
}
return $this->db->putActivity($id, $attributes);
}
开发者ID:nicolargo,项目名称:frontend,代码行数:16,代码来源:Activity.php
示例14: settings
/**
* User's settings page
*
* @return void
*/
public function settings()
{
getAuthentication()->requireAuthentication();
$userObj = new User();
$credentials = $this->api->invoke('/oauth/list.json', EpiRoute::httpGet);
$groups = $this->api->invoke('/groups/list.json', EpiRoute::httpGet);
$webhooks = $this->api->invoke('/webhooks/list.json', EpiRoute::httpGet);
$plugins = $this->api->invoke('/plugins/list.json', EpiRoute::httpGet);
$mobilePassphrase = $userObj->getMobilePassphrase();
if (!empty($mobilePassphrase)) {
$mobilePassphrase['minutes'] = ceil(($mobilePassphrase['expiresAt'] - time()) / 60);
}
$template = sprintf('%s/settings.php', $this->config->paths->templates);
$body = $this->template->get($template, array('crumb' => getSession()->get('crumb'), 'plugins' => $plugins['result'], 'credentials' => $credentials['result'], 'webhooks' => $webhooks['result'], 'groups' => $groups['result'], 'mobilePassphrase' => $mobilePassphrase));
$this->theme->display('template.php', array('body' => $body, 'page' => 'settings'));
}
开发者ID:nicolargo,项目名称:frontend,代码行数:21,代码来源:UserController.php
示例15: upgradePost
public function upgradePost()
{
getAuthentication()->requireAuthentication();
getUpgrade()->performUpgrade();
$configObj = getConfig();
// Backwards compatibility
// TODO remove in 2.0
$basePath = dirname(Epi::getPath('config'));
$configFile = sprintf('%s/userdata/configs/%s.ini', $basePath, getenv('HTTP_HOST'));
if (!file_exists($configFile)) {
$configFile = sprintf('%s/generated/%s.ini', Epi::getPath('config'), getenv('HTTP_HOST'));
}
$config = $configObj->getString($configFile);
$config = preg_replace('/lastCodeVersion *= *"\\d+\\.\\d+\\.\\d+"/', sprintf('lastCodeVersion="%s"', getUpgrade()->getCurrentVersion()), $config);
$configObj->write($configFile, $config);
$this->route->redirect('/');
}
开发者ID:gg1977,项目名称:frontend,代码行数:17,代码来源:UpgradeController.php
示例16: send
public function send($type, $data)
{
getAuthentication()->requireAuthentication();
getAuthentication()->requireCrumb();
$email = $this->session->get('email');
if (empty($email) || empty($_POST['message']) || empty($_POST['recipients'])) {
return $this->error('Not all parameters were passed in', false);
}
$emailer = new Emailer($email);
$emailer->setRecipients(array_merge(array($email), (array) explode(',', $_POST['recipients'])));
if ($type === 'photo') {
$status = $this->sendPhotoEmail($data, $emailer);
} else {
$status = $this->sendAlbumEmail($data, $emailer);
}
if (!$status) {
return $this->error('Could not complete request', false);
}
return $this->success('yes', array('data' => $data, 'post' => $_POST));
}
开发者ID:gg1977,项目名称:frontend,代码行数:20,代码来源:ApiShareController.php
示例17: upload
/**
* Upload a video.
*
* @return string standard json envelope
*/
public function upload()
{
getAuthentication()->requireAuthentication();
getAuthentication()->requireCrumb();
$httpObj = new Http();
$attributes = $_REQUEST;
$this->plugin->invoke('onVideoUpload');
// this determines where to get the photo from and populates $localFile and $name
extract($this->parseVideoFromRequest());
// TODO put this in a whitelist function (see replace())
if (isset($attributes['__route__'])) {
unset($attributes['__route__']);
}
if (isset($attributes['photo'])) {
unset($attributes['photo']);
}
if (isset($attributes['crumb'])) {
unset($attributes['crumb']);
}
$videoId = false;
$attributes['video'] = true;
$attributes['hash'] = sha1_file($localFile);
$attributes['width'] = $this->config->photos->baseSize;
$attributes['height'] = $this->config->photos->baseSize;
$videoId = $this->video->upload($localFile, $name, $attributes);
if ($videoId) {
$apiResp = $this->api->invoke("/{$this->apiVersion}/photo/{$videoId}/view.json", EpiRoute::httpGet, array('_GET' => array()));
$video = $apiResp['result'];
$permission = isset($attributes['permission']) ? $attributes['permission'] : 0;
// TODO webhooks and things
if ($video) {
}
$this->plugin->setData('video', $video);
$this->plugin->setData('videoId', $videoId);
$this->plugin->invoke('onVideoUploaded');
$this->user->setAttribute('stickyPermission', $permission);
$this->user->setAttribute('stickyLicense', $video['license']);
return $this->created("Video {$videoId} uploaded successfully", $video);
}
return $this->error("File upload failure", false);
}
开发者ID:gg1977,项目名称:frontend,代码行数:46,代码来源:ApiVideoController.php
示例18: update
public function update($plugin)
{
getAuthentication()->requireAuthentication();
$params = $_POST;
$pluginObj = getPlugin();
$conf = $pluginObj->loadConf($plugin);
if (!$conf) {
return $this->error('Cannot update settings for a deactivated plugin, try activating first.', false);
}
foreach ($conf as $name => $value) {
if (isset($_POST[$name])) {
$conf[$name] = $_POST[$name];
}
}
$status = $pluginObj->writeConf($plugin, $this->utility->generateIniString($conf));
if ($status) {
return $this->success('Plugin updated successfully', $conf);
} else {
return $this->error('Could not update plugin', false);
}
}
开发者ID:nicolargo,项目名称:frontend,代码行数:21,代码来源:ApiPluginController.php
示例19: updateIndex
public function updateIndex($albumId, $type, $action)
{
getAuthentication()->requireAuthentication();
getAuthentication()->requireCrumb();
if (!isset($_POST['ids']) || empty($_POST['ids'])) {
return $this->error('Please provide ids', false);
}
$cnt = array('success' => 0, 'failure' => 0);
switch ($action) {
case 'add':
$resp = $this->album->addElement($albumId, $type, $_POST['ids']);
break;
case 'remove':
$resp = $this->album->removeElement($albumId, $type, $_POST['ids']);
break;
}
if (!$resp) {
return $this->error('All items were not updated', false);
}
return $this->success('All items updated', true);
}
开发者ID:nicolargo,项目名称:frontend,代码行数:21,代码来源:ApiAlbumController.php
示例20: upload
/**
* Upload new media.
*
* @return string standard json envelope
*/
public function upload()
{
$httpObj = new Http();
$attributes = $_REQUEST;
$albums = array();
if (isset($attributes['albums']) && !empty($attributes['albums'])) {
$albums = (array) explode(',', $attributes['albums']);
}
$token = null;
if (isset($attributes['token']) && !empty($attributes['token'])) {
$shareTokenObj = new ShareToken();
$tokenArr = $shareTokenObj->get($attributes['token']);
if (empty($tokenArr) || $tokenArr['type'] != 'upload') {
return $this->forbidden('No permissions with the passed in token', false);
}
$attributes['albums'] = $tokenArr['data'];
$token = $tokenArr['id'];
$attributes['permission'] = '0';
} else {
getAuthentication()->requireAuthentication(array(Permission::create), $albums);
getAuthentication()->requireCrumb();
}
// determine localFile
extract($this->parseMediaFromRequest());
// Get file mimetype by instantiating a photo object
// getMediaType is defined in parent abstract class Media
$photoObj = new Photo();
$mediaType = $photoObj->getMediaType($localFile);
// Invoke type-specific
switch ($mediaType) {
case Media::typePhoto:
return $this->api->invoke("/{$this->apiVersion}/photo/upload.json", EpiRoute::httpPost);
case Media::typeVideo:
return $this->api->invoke("/{$this->apiVersion}/video/upload.json", EpiRoute::httpPost);
}
return $this->error('Unsupported media type', false);
}
开发者ID:gg1977,项目名称:frontend,代码行数:42,代码来源:ApiMediaController.php
注:本文中的getAuthentication函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论