Skip to content

Commit 2f10901

Browse files
committed
fixes prompt=login process
1 parent ada25fd commit 2f10901

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/Controller/OAuthController.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function initialize(): void
5454
* on Controller.initialize
5555
*
5656
* @param Event $event the event
57-
* @return void
57+
* @return Response|null
5858
*/
59-
public function beforeFilter(Event $event): void
59+
public function beforeFilter(Event $event): ?Response
6060
{
6161
// if prompt=login on authorize action, then logout and remove prompt params
6262
if (
@@ -67,11 +67,14 @@ public function beforeFilter(Event $event): void
6767

6868
$query = $this->request->getQueryParams();
6969
unset($query['prompt']);
70-
$uri = $this->request->getUri();
71-
$this->request = $this->request
72-
->withQueryParams($query)
73-
->withUri($uri->withQuery(http_build_query($query)));
70+
71+
return $this->redirect([
72+
'action' => 'authorize',
73+
'?' => $query,
74+
]);
7475
}
76+
77+
return null;
7578
}
7679

7780
/**

tests/TestCase/Controller/OAuthControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testAuthorizeLoginRedirectWhenWithPromptLogin()
139139
$this->get($authorizeUrl);
140140

141141
$this->assertSession(null, 'Auth.User.id', 'will logged out');
142-
$this->assertRedirect(['plugin' => false, 'controller' => 'Users', 'action' => 'login', '?' => ['redirect' => $expectedLoginRedirectUrl]]);
142+
$this->assertRedirect($expectedLoginRedirectUrl);
143143
}
144144

145145
public function testAuthorizationCodeDeny()

0 commit comments

Comments
 (0)