From 5912b9f9fd2a7cf1794d828d89c5936c90915d83 Mon Sep 17 00:00:00 2001 From: Terje Holene Date: Tue, 25 Aug 2020 16:17:12 +0200 Subject: [PATCH] Changed Logout to be a POST (#4668) Changed Logout to be a POST --- .../src/designer/backend/Controllers/HomeController.cs | 2 +- .../shared/navigation/drawer/TabletDrawerMenu.tsx | 9 ++++++--- .../shared/navigation/main-header/profileMenu.tsx | 10 ++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/studio/src/designer/backend/Controllers/HomeController.cs b/src/studio/src/designer/backend/Controllers/HomeController.cs index 7399c0f1942..2fb88ac7a4f 100644 --- a/src/studio/src/designer/backend/Controllers/HomeController.cs +++ b/src/studio/src/designer/backend/Controllers/HomeController.cs @@ -181,7 +181,7 @@ await HttpContext.SignInAsync( public async Task Logout() { await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - return LocalRedirect("/repos/user/logout"); + return LocalRedirect("/"); } /// diff --git a/src/studio/src/designer/frontend/shared/navigation/drawer/TabletDrawerMenu.tsx b/src/studio/src/designer/frontend/shared/navigation/drawer/TabletDrawerMenu.tsx index 70f915421f5..4fcb05e19bf 100644 --- a/src/studio/src/designer/frontend/shared/navigation/drawer/TabletDrawerMenu.tsx +++ b/src/studio/src/designer/frontend/shared/navigation/drawer/TabletDrawerMenu.tsx @@ -12,6 +12,7 @@ import { Link } from 'react-router-dom'; import { IMenuItem, leftDrawerMenuSettings } from './drawerMenuSettings'; import { mainMenuSettings } from './drawerMenuSettings'; import { styles } from './tabletDrawerMenustyle'; +import { post } from '../../utils/networking'; export interface ITabletDrawerMenuProps { classes: any; @@ -61,9 +62,11 @@ class TabletDrawerMenu extends React.Component { - if (window) { - window.location.href = '/Home/Logout'; - } + const altinnWindow: Window = window; + const url = `${altinnWindow.location.origin}/repos/user/logout`; + post(url).then(() => { + window.location.assign(`${altinnWindow.location.origin}/Home/Logout`); + }); return true; } diff --git a/src/studio/src/designer/frontend/shared/navigation/main-header/profileMenu.tsx b/src/studio/src/designer/frontend/shared/navigation/main-header/profileMenu.tsx index 406be297bfd..66776929c09 100644 --- a/src/studio/src/designer/frontend/shared/navigation/main-header/profileMenu.tsx +++ b/src/studio/src/designer/frontend/shared/navigation/main-header/profileMenu.tsx @@ -6,6 +6,7 @@ import AccountCircle from '@material-ui/icons/AccountCircle'; import * as React from 'react'; import { IAltinnWindow } from '../../types'; import { altinnStudioDocsUrl, repositoryUrl } from '../../utils/urlHelper'; +import { post } from '../../utils/networking'; export interface IProfileMenuComponentProps { showlogout?: boolean; @@ -51,10 +52,11 @@ class ProfileMenuComponent extends React.Component { - this.setState({ anchorEl: null }); - if (window) { - window.location.href = '/Home/Logout'; - } + const altinnWindow: Window = window; + const url = `${altinnWindow.location.origin}/repos/user/logout`; + post(url).then(() => { + window.location.assign(`${altinnWindow.location.origin}/Home/Logout`); + }); return true; }