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


PHP SecurityToken::checkRequest方法代码示例

本文整理汇总了PHP中SecurityToken::checkRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityToken::checkRequest方法的具体用法?PHP SecurityToken::checkRequest怎么用?PHP SecurityToken::checkRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SecurityToken的用法示例。


在下文中一共展示了SecurityToken::checkRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCheckRequest

 public function testCheckRequest()
 {
     $t = new SecurityToken();
     $n = $t->getName();
     $t->setValue(null);
     $r = new SS_HTTPRequest('GET', 'dummy', array($n => 'invalidtoken'));
     $this->assertFalse($t->checkRequest($r), 'Any token is invalid if no token is stored');
     $t->setValue(null);
     $r = new SS_HTTPRequest('GET', 'dummy', array($n => null));
     $this->assertFalse($t->checkRequest($r), 'NULL token is invalid if no token is stored');
     $t->setValue('mytoken');
     $r = new SS_HTTPRequest('GET', 'dummy', array($n => 'invalidtoken'));
     $this->assertFalse($t->checkRequest($r), 'Invalid token returns false');
     $t->setValue('mytoken');
     $r = new SS_HTTPRequest('GET', 'dummy', array($n => 'mytoken'));
     $this->assertTrue($t->checkRequest($r), 'Valid token returns true');
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:17,代码来源:SecurityTokenTest.php

示例2: sendSignupConfirmation

 public function sendSignupConfirmation($request)
 {
     $body = $this->request->getBody();
     $json = json_decode($body, true);
     if (!$this->securityToken->checkRequest($request)) {
         $response = new SS_HTTPResponse();
         $response->setStatusCode(403);
         $response->addHeader('Content-Type', 'application/json');
         $response->setBody(json_encode("Error"));
         return $response;
     }
     $this->securityToken->reset();
     $to = $json['email'];
     $news_update_email_from = defined('NEWS_UPDATE_EMAIL_FROM') ? NEWS_UPDATE_EMAIL_FROM : 'openstacknews@openstack.org';
     $user_name = sprintf('%s %s', $json['first_name'], $json['last_name']);
     $email = EmailFactory::getInstance()->buildEmail('noreply@openstack.org', $to, 'Thank you for subscribing to OpenStack Foundation News updates');
     $email->setTemplate('NewsPageSignupConfirmationEMail');
     $email->populateTemplate(array('UserName' => $user_name, 'NewsUpdateEmailFrom' => $news_update_email_from));
     $email->send();
     return 'OK';
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:21,代码来源:NewsPage_Controller.php

示例3: emitPackagePurchaseOrder

 /**
  * @param $request
  * @return SS_HTTPResponse|string
  */
 public function emitPackagePurchaseOrder($request)
 {
     if (!Director::is_ajax()) {
         return $this->forbiddenError();
     }
     if (!$this->packagePurchaseOrderSecurityToken->checkRequest($request)) {
         return $this->forbiddenError();
     }
     $body = $this->request->getBody();
     $json = json_decode($body, true);
     $this->packagePurchaseOrderSecurityToken->reset();
     try {
         $this->getPackagePurchaseOrderManager()->registerPurchaseOrder($json, new NewPurchaseOrderEmailMessageSender());
     } catch (EntityValidationException $ex1) {
         SS_Log::log($ex1, SS_Log::WARN);
         return $this->validationError($ex1->getMessages());
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         return $this->serverError();
     }
     return $this->ok(array('token' => $this->packagePurchaseOrderSecurityToken->getValue()));
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:26,代码来源:SummitSponsorPage.php


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