mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
fix: add X-User-Id header to logout response before clearing the user session
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
This commit is contained in:
parent
462ea0e7f7
commit
b6e18bf28a
2 changed files with 8 additions and 2 deletions
|
|
@ -79,8 +79,9 @@ class LoginController extends Controller {
|
|||
#[FrontpageRoute(verb: 'GET', url: '/logout')]
|
||||
public function logout() {
|
||||
$loginToken = $this->request->getCookie('nc_token');
|
||||
if (!is_null($loginToken)) {
|
||||
$this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);
|
||||
$uid = $this->userSession->getUser()?->getUID();
|
||||
if ($loginToken !== null && $uid !== null) {
|
||||
$this->config->deleteUserValue($uid, 'login_token', $loginToken);
|
||||
}
|
||||
$this->userSession->logout();
|
||||
|
||||
|
|
@ -99,6 +100,10 @@ class LoginController extends Controller {
|
|||
$response->addHeader('Clear-Site-Data', '"cache", "storage"');
|
||||
}
|
||||
|
||||
if ($uid !== null) {
|
||||
$response->addHeader('X-User-Id', $uid);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ class LoginControllerTest extends TestCase {
|
|||
|
||||
$expected = new RedirectResponse('/login');
|
||||
$expected->addHeader('Clear-Site-Data', '"cache", "storage"');
|
||||
$expected->addHeader('X-User-Id', 'JohnDoe');
|
||||
$this->assertEquals($expected, $this->loginController->logout());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue