Merge pull request #14342 from annando/issue-14303

Issue 14303: Fixes %3f problem with OAuth login
This commit is contained in:
Tobias Diekershoff 2024-08-04 16:56:33 +02:00 committed by GitHub
commit be7e2e4984
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -45,7 +45,7 @@ class Acknowledge extends BaseApi
protected function content(array $request = []): string
{
DI::session()->set('return_path', $_REQUEST['return_path'] ?? '');
DI::session()->set('return_path', 'oauth/authorize?' . $request['return_authorize']);
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('oauth_authorize.tpl'), [
'$title' => DI::l10n()->t('Authorize application connection'),

View file

@ -68,19 +68,19 @@ class Authorize extends BaseApi
$redirect_request = $_REQUEST;
unset($redirect_request['pagename']);
$redirect = 'oauth/authorize?' . http_build_query($redirect_request);
$redirect = http_build_query($redirect_request);
$uid = DI::userSession()->getLocalUserId();
if (empty($uid)) {
Logger::info('Redirect to login');
DI::app()->redirect('login?return_path=' . urlencode($redirect));
DI::app()->redirect('login?' . http_build_query(['return_authorize' => $redirect]));
} else {
Logger::info('Already logged in user', ['uid' => $uid]);
}
if (!OAuth::existsTokenForUser($application, $uid) && !DI::session()->get('oauth_acknowledge')) {
Logger::info('Redirect to acknowledge');
DI::app()->redirect('oauth/acknowledge?' . http_build_query(['return_path' => $redirect, 'application' => $application['name']]));
DI::app()->redirect('oauth/acknowledge?' . http_build_query(['return_authorize' => $redirect, 'application' => $application['name']]));
}
DI::session()->remove('oauth_acknowledge');

View file

@ -60,7 +60,11 @@ class Login extends BaseModule
protected function content(array $request = []): string
{
$return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ;
if (!empty($request['return_authorize'])) {
$return_path = 'oauth/authorize?' . $request['return_authorize'];
} else {
$return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ;
}
if ($this->session->getLocalUserId()) {
$this->baseUrl->redirect($return_path);