Skip to content

Commit

Permalink
application id fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisoft committed Jan 30, 2017
1 parent 196f873 commit 8929ec9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/Request/AlexaRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,20 @@ public function getSlots()
return array_map(function($obj) { return $obj->value; }, get_object_vars($this->getIntent()->slots));
}

/**
* @return mixed
* @throws \Exception
*/
public function getApplicationId()
{
if (property_exists($this, 'session')) {
return $this->session->application->applicationId;
}
if (property_exists($this, 'context')) {
return $this->context->application->applicationId;
}
throw new \Exception('Application ID not found');
}


}
14 changes: 7 additions & 7 deletions src/Request/RequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ class RequestValidator
{

/**
* @var
* @var AlexaRequest
*/
private $request;

/**
* @var
* @var string[]
*/
private $errors;

/**
* @param $request
* @param AlexaRequest $request
*/
public function __construct($request)
public function __construct(AlexaRequest $request)
{
$this->request = $request;
}

/**
* @param $applicationId
* @param string $applicationId
*
* @return bool
*/
Expand Down Expand Up @@ -93,13 +93,13 @@ private function validateSignatureUrl()
}

/**
* @param $applicationId
* @param string $applicationId
*
* @return bool
*/
private function validateApplicationId($applicationId)
{
if( $this->request->session->application->applicationId != $applicationId) {
if( $this->request->getApplicationId() != $applicationId) {
$this->errors[] = 'Invalid application id';
return false;
}
Expand Down

0 comments on commit 8929ec9

Please sign in to comment.