@@ -38,6 +38,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
38
38
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
39
39
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys' ;
40
40
import { ICommandService } from 'vs/platform/commands/common/commands' ;
41
+ // import { logger } from 'vs/server/node/logger';
41
42
42
43
export abstract class MenubarControl extends Disposable {
43
44
@@ -719,6 +720,30 @@ export class CustomMenubarControl extends MenubarControl {
719
720
} ) ) ;
720
721
}
721
722
723
+ webNavigationActions . push ( new Action ( 'logout' , nls . localize ( 'logout' , "Log out" ) , undefined , true ,
724
+ async ( event ?: MouseEvent ) => {
725
+ const COOKIE_KEY = 'key' ;
726
+ const loginCookie = DOM . getCookieValue ( COOKIE_KEY ) ;
727
+
728
+ // logger.info('Logging out of code-server');
729
+
730
+ if ( loginCookie ) {
731
+ // logger.info(`Removing cookie under ${COOKIE_KEY}`);
732
+
733
+ if ( document && document . cookie ) {
734
+ // We delete the cookie by setting the expiration to a date/time in the past
735
+ document . cookie = COOKIE_KEY + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;' ;
736
+ window . location . href = '/login' ;
737
+ } else {
738
+ console . log ( 'could not delete cookie.' ) ;
739
+ // logger.warn('Could not delete cookie because document and/or document.cookie is undefined');
740
+ }
741
+ } else {
742
+ console . log ( 'could not log out because we could not find cookie' ) ;
743
+ // logger.warn('Could not log out because we could not find cookie');
744
+ }
745
+ } ) ) ;
746
+
722
747
const otherActions = this . getWebNavigationMenuItemActions ( ) . map ( action => {
723
748
const title = typeof action . item . title === 'string'
724
749
? action . item . title
0 commit comments