Use PSR-7 responses in GithubAuthAction
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 Aug 2021 13:59:01 +0000 (15:59 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 11 Aug 2021 14:29:53 +0000 (16:29 +0200)
wcfsetup/install/files/lib/action/GithubAuthAction.class.php

index 1efc49a2b19b4836652b1563af410d114440988c..22c5e3356604a92655cac1970b15d4aa8cc149e7 100644 (file)
@@ -3,6 +3,7 @@
 namespace wcf\action;
 
 use GuzzleHttp\Psr7\Request;
+use Laminas\Diactoros\Response\RedirectResponse;
 use Psr\Http\Client\ClientExceptionInterface;
 use wcf\data\user\User;
 use wcf\form\RegisterForm;
@@ -12,7 +13,6 @@ use wcf\system\request\LinkHandler;
 use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\authentication\oauth\User as OauthUser;
 use wcf\system\WCF;
-use wcf\util\HeaderUtil;
 use wcf\util\JSON;
 use wcf\util\StringUtil;
 
@@ -131,9 +131,9 @@ final class GithubAuthAction extends AbstractOauth2Action
                     new UserLoggedIn($user)
                 );
 
-                HeaderUtil::redirect(LinkHandler::getInstance()->getLink());
-
-                exit;
+                return new RedirectResponse(
+                    LinkHandler::getInstance()->getLink()
+                );
             }
         } else {
             WCF::getSession()->register('__3rdPartyProvider', 'github');
@@ -144,9 +144,9 @@ final class GithubAuthAction extends AbstractOauth2Action
 
                 WCF::getSession()->register('__oauthUser', $oauthUser);
 
-                HeaderUtil::redirect(LinkHandler::getInstance()->getLink('AccountManagement') . '#3rdParty');
-
-                exit;
+                return new RedirectResponse(
+                    LinkHandler::getInstance()->getLink('AccountManagement') . '#3rdParty'
+                );
             } else {
                 // This account does not belong to anyone and we are not logged in.
                 // Thus we want to connect this account to a newly registered user.
@@ -180,9 +180,10 @@ final class GithubAuthAction extends AbstractOauth2Action
                 WCF::getSession()->register('noRegistrationCaptcha', true);
 
                 WCF::getSession()->update();
-                HeaderUtil::redirect(LinkHandler::getInstance()->getControllerLink(RegisterForm::class));
 
-                exit;
+                return new RedirectResponse(
+                    LinkHandler::getInstance()->getControllerLink(RegisterForm::class)
+                );
             }
         }
     }