mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 18:51:53 +05:30
Merge pull request #431 from juliangut/redirectUri
V5 - use Psr\Http\Message\UriInterface
This commit is contained in:
commit
770bda8f10
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user