-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PBS Account registration flow route
- Loading branch information
Christopher C. Wells
committed
Feb 17, 2022
1 parent
da5d9ae
commit 1971386
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Drupal\social_auth_pbs\Controller; | ||
|
||
use Drupal\Core\Routing\TrustedRedirectResponse; | ||
|
||
/** | ||
* Returns responses for special Social Auth PBS Account register routes. | ||
* | ||
* This controller generates a URL that sends the user first through an account | ||
* creation flow and then through the regular OAuth2 authorization flow. | ||
*/ | ||
class PbsRegisterController extends PbsAuthController { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function redirectToProvider() { | ||
$response = parent::redirectToProvider(); | ||
if ($response instanceof TrustedRedirectResponse) { | ||
$url_parts = parse_url($response->getTargetUrl()); | ||
$next = urlencode("{$url_parts['path']}?{$url_parts['query']}"); | ||
$register_url = "{$url_parts['scheme']}://{$url_parts['host']}/oauth2/register/?next=$next"; | ||
$response->setTrustedTargetUrl($register_url); | ||
} | ||
return $response; | ||
} | ||
|
||
} |