Replaced all the setHeader() with the new setLocation().

This should solve all the downstream bugs on nginx.
This commit is contained in:
Abel Hoogeveen 2023-02-14 15:08:20 +01:00
parent 0ed0fd0fac
commit c0b04a4434
1 changed files with 11 additions and 11 deletions

View File

@ -89,7 +89,7 @@ class AuthenticationHtmlView extends WebView
$location = $this->input->get("location"); $location = $this->input->get("location");
$redirect = is_null($location) ? "/" : $location; $redirect = is_null($location) ? "/" : $location;
if ($this->controller->session->user->id !== "0") if ($this->controller->session->user->id !== "0")
$this->output->setHeader("Location: " . $redirect); $this->output->setLocation($redirect);
// Prepare form // Prepare form
$form = $this->forms->getCachedForm(function (Form $form) { $form = $this->forms->getCachedForm(function (Form $form) {
@ -139,7 +139,7 @@ class AuthenticationHtmlView extends WebView
$this->controller->login($form->identifier->getValue(), $form->password->getValue(), $form->remember->getValue(), $context); $this->controller->login($form->identifier->getValue(), $form->password->getValue(), $form->remember->getValue(), $context);
// And redirect the user // And redirect the user
$this->output->setHeader("Location: " . $redirect); $this->output->setLocation($redirect);
} catch (LoginErrorException $e) { } catch (LoginErrorException $e) {
$form->invalidate(true); $form->invalidate(true);
$form->addFormError($e->getMessage()); $form->addFormError($e->getMessage());
@ -159,17 +159,17 @@ class AuthenticationHtmlView extends WebView
$this->controller->logout(); $this->controller->logout();
$location = $this->input->get("location"); $location = $this->input->get("location");
$redirect = is_null($location) ? "/" : $location; $redirect = is_null($location) ? "/" : $location;
$this->output->setHeader("Location: " . $redirect); $this->output->setLocation($redirect);
} }
public function register() public function register()
{ {
// First check if the registration is enabled // First check if the registration is enabled
if (!$this->plugin->getConfig()->get("register_enabled")) if (!$this->plugin->getConfig()->get("register_enabled"))
$this->output->setHeader("Location: /"); $this->output->setLocation("/");
if ($this->controller->session->user->id !== "0") if ($this->controller->session->user->id !== "0")
$this->output->setHeader("Location: /"); $this->output->setLocation("/");
// Prepare form // Prepare form
$form = $this->forms->getCachedForm(function (Form $form) { $form = $this->forms->getCachedForm(function (Form $form) {
@ -249,7 +249,7 @@ class AuthenticationHtmlView extends WebView
// If the token is empty, report so // If the token is empty, report so
if (empty($token)) if (empty($token))
$this->output->setHeader("Location: /"); $this->output->setLocation("/");
// Generate basic form // Generate basic form
$form = new Form("ResendVerifyEmailForm", "Resend verification email"); $form = new Form("ResendVerifyEmailForm", "Resend verification email");
@ -294,10 +294,10 @@ class AuthenticationHtmlView extends WebView
if (is_null($user->password)) if (is_null($user->password))
{ {
$token = $this->controller->createResetToken($user); $token = $this->controller->createResetToken($user);
$this->output->setHeader("Location: " . $this->plugin->getAuthenticationURL() . "/reset_password?t=" . $token); $this->output->setLocation($this->plugin->getAuthenticationURL() . "/reset_password?t=" . $token);
} }
else else
$this->output->setHeader("Location: " . $this->plugin->getAuthenticationURL()); $this->output->setLocation($this->plugin->getAuthenticationURL());
return "Token verified"; return "Token verified";
} }
@ -306,11 +306,11 @@ class AuthenticationHtmlView extends WebView
{ {
// If user is already logged in, redirect to homepage // If user is already logged in, redirect to homepage
if ($this->controller->session->user->id !== "0") if ($this->controller->session->user->id !== "0")
$this->output->setHeader("Location: /"); $this->output->setLocation("/");
// Check if forgot password is disabled // Check if forgot password is disabled
if (!$this->plugin->getConfig()->get("forgot_password_enabled")) if (!$this->plugin->getConfig()->get("forgot_password_enabled"))
$this->output->setHeader("Location: /"); $this->output->setLocation("/");
// Prepare form // Prepare form
$form = $this->forms->getCachedForm(function (Form $form){ $form = $this->forms->getCachedForm(function (Form $form){
@ -384,7 +384,7 @@ class AuthenticationHtmlView extends WebView
// Reset by controller // Reset by controller
try { try {
$this->controller->resetPassword($token, $password); $this->controller->resetPassword($token, $password);
$this->output->setHeader("Location: " . $this->plugin->getAuthenticationURL() . "/login"); $this->output->setLocation($this->plugin->getAuthenticationURL() . "/login");
} catch (LoginErrorException $e) { } catch (LoginErrorException $e) {
$form->invalidate(true); $form->invalidate(true);
$form->addFormError($e->getMessage()); $form->addFormError($e->getMessage());