当前位置: 首页>>代码示例>>PHP>>正文


PHP getAuthentication函数代码示例

本文整理汇总了PHP中getAuthentication函数的典型用法代码示例。如果您正苦于以下问题:PHP getAuthentication函数的具体用法?PHP getAuthentication怎么用?PHP getAuthentication使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getAuthentication函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的getAuthentication函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。