Skip to content

Commit f9ced6c

Browse files
committed
fix #5153 updated: chose whether to respond with empty response or redirection
Check whether header 'X-Requested-With' is not empty, similar as done in HandleExceptions.php so actual value of the header may change and not affect this behaviour.
1 parent 02310b2 commit f9ced6c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/Http/RequestHandlers/Logout.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
use Psr\Http\Message\ServerRequestInterface;
3030
use Psr\Http\Server\RequestHandlerInterface;
3131

32+
use function redirect;
3233
use function response;
34+
use function route;
3335

3436
/**
3537
* Perform a logout.
@@ -51,6 +53,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface
5153
FlashMessages::addMessage(I18N::translate('You have signed out.'));
5254
}
5355

54-
return response();
56+
if ($request->getHeaderLine('X-Requested-With') !== '') {
57+
// Ajax request - send empty response
58+
return response();
59+
} else {
60+
// Form submission - redirect to home page
61+
return redirect(route(HomePage::class));
62+
}
5563
}
5664
}

0 commit comments

Comments
 (0)