本文整理汇总了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');
}
示例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';
}
示例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()));
}