Merge pull request #431 from juliangut/redirectUri

V5 - use Psr\Http\Message\UriInterface
This commit is contained in:
Alex Bilbie 2016-02-11 17:35:33 +00:00
commit 770bda8f10
2 changed files with 7 additions and 35 deletions

View File

@ -6,6 +6,7 @@ use League\OAuth2\Server\Utils\RedirectUri;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\Uri;
class OAuthServerException extends \Exception
{
@ -236,7 +237,12 @@ class OAuthServerException extends \Exception
}
if ($this->redirectUri !== null) {
$headers['Location'] = RedirectUri::make($this->redirectUri, $payload);
$redirectUri = new Uri($this->redirectUri);
parse_str($redirectUri->getQuery(), $redirectPayload);
$headers['Location'] = (string) $redirectUri->withQuery(http_build_query(
array_merge($redirectPayload, $payload)
));
}
foreach ($headers as $header => $content) {

View File

@ -1,34 +0,0 @@
<?php
/**
* OAuth 2.0 Redirect URI generator
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @copyright Copyright (c) Alex Bilbie
* @license http://mit-license.org/
* @link https://github.com/thephpleague/oauth2-server
*/
namespace League\OAuth2\Server\Utils;
/**
* RedirectUri class
*/
class RedirectUri
{
/**
* Generate a new redirect uri
*
* @param string $uri The base URI
* @param array $params The query string parameters
* @param string $queryDelimiter The query string delimiter (default: "?")
*
* @return string The updated URI
*/
public static function make($uri, $params = [], $queryDelimiter = '?')
{
$uri .= (strstr($uri, $queryDelimiter) === false) ? $queryDelimiter : '&';
return $uri . http_build_query($params);
}
}