Issue 14303: Fixes %3f problem with OAuth login

This commit is contained in:
Michael 2024-08-03 19:21:29 +00:00
parent 26f8392754
commit efee399397
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 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'), [ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('oauth_authorize.tpl'), [
'$title' => DI::l10n()->t('Authorize application connection'), '$title' => DI::l10n()->t('Authorize application connection'),

View file

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

View file

@ -60,7 +60,11 @@ class Login extends BaseModule
protected function content(array $request = []): string 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()) { if ($this->session->getLocalUserId()) {
$this->baseUrl->redirect($return_path); $this->baseUrl->redirect($return_path);