more robust oauth

This commit is contained in:
Jan Prochazka
2022-11-27 10:43:25 +01:00
parent b1ae7d53b9
commit d84adcca5d
5 changed files with 51 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ import runCommand from './runCommand';
import { openWebLink } from '../utility/exportFileTools';
import { getSettings } from '../utility/metadataLoaders';
import { isMac } from '../utility/common';
import { internalRedirectTo } from '../clientAuth';
// function themeCommand(theme: ThemeDefinition) {
// return {
@@ -549,7 +550,20 @@ registerCommand({
name: 'Logout',
testEnabled: () => getCurrentConfig()?.login != null,
onClick: () => {
window.location.href = 'config/logout';
const config = getCurrentConfig();
if (config.oauth) {
localStorage.removeItem('accessToken');
if (config.oauthLogout) {
window.location.href = config.oauthLogout;
} else {
internalRedirectTo('/?page=not-logged');
}
} else if (config.isLoginForm) {
localStorage.removeItem('accessToken');
internalRedirectTo('/?page=not-logged');
} else {
window.location.href = 'config/logout';
}
},
});