File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,16 @@ social_auth_pbs.redirect_to_pbs:
8
8
options :
9
9
no_cache : TRUE
10
10
11
+ social_auth_pbs.redirect_to_pbs_register :
12
+ path : ' user/login/pbs-register'
13
+ defaults :
14
+ _controller : ' \Drupal\social_auth_pbs\Controller\PbsRegisterController::redirectToProvider'
15
+ requirements :
16
+ # Anonymous users can log in, but authenticated users can also associate a new provider.
17
+ _access : ' TRUE'
18
+ options :
19
+ no_cache : TRUE
20
+
11
21
social_auth_pbs.redirect_to_apple :
12
22
path : ' user/login/pbs-apple'
13
23
defaults :
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drupal \social_auth_pbs \Controller ;
4
+
5
+ use Drupal \Core \Routing \TrustedRedirectResponse ;
6
+
7
+ /**
8
+ * Returns responses for special Social Auth PBS Account register routes.
9
+ *
10
+ * This controller generates a URL that sends the user first through an account
11
+ * creation flow and then through the regular OAuth2 authorization flow.
12
+ */
13
+ class PbsRegisterController extends PbsAuthController {
14
+
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ public function redirectToProvider () {
19
+ $ response = parent ::redirectToProvider ();
20
+ if ($ response instanceof TrustedRedirectResponse) {
21
+ $ url_parts = parse_url ($ response ->getTargetUrl ());
22
+ $ next = urlencode ("{$ url_parts ['path ' ]}? {$ url_parts ['query ' ]}" );
23
+ $ register_url = "{$ url_parts ['scheme ' ]}:// {$ url_parts ['host ' ]}/oauth2/register/?next= $ next " ;
24
+ $ response ->setTrustedTargetUrl ($ register_url );
25
+ }
26
+ return $ response ;
27
+ }
28
+
29
+ }
You can’t perform that action at this time.
0 commit comments