@@ -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 { ILogService } from 'vs/platform/log/common/log' ;
41
42
42
43
export abstract class MenubarControl extends Disposable {
43
44
@@ -311,7 +312,8 @@ export class CustomMenubarControl extends MenubarControl {
311
312
@IThemeService private readonly themeService : IThemeService ,
312
313
@IWorkbenchLayoutService private readonly layoutService : IWorkbenchLayoutService ,
313
314
@IHostService protected readonly hostService : IHostService ,
314
- @ICommandService commandService : ICommandService
315
+ @ICommandService commandService : ICommandService ,
316
+ @ILogService private readonly logService : ILogService
315
317
) {
316
318
super ( menuService , workspacesService , contextKeyService , keybindingService , configurationService , labelService , updateService , storageService , notificationService , preferencesService , environmentService , accessibilityService , hostService , commandService ) ;
317
319
@@ -719,6 +721,28 @@ export class CustomMenubarControl extends MenubarControl {
719
721
} ) ) ;
720
722
}
721
723
724
+ webNavigationActions . push ( new Action ( 'logout' , nls . localize ( 'logout' , "Log out" ) , undefined , true ,
725
+ async ( event ?: MouseEvent ) => {
726
+ const COOKIE_KEY = 'key' ;
727
+ const loginCookie = DOM . getCookieValue ( COOKIE_KEY ) ;
728
+
729
+ this . logService . info ( 'Logging out of code-server' ) ;
730
+
731
+ if ( loginCookie ) {
732
+ this . logService . info ( `Removing cookie under ${ COOKIE_KEY } ` ) ;
733
+
734
+ if ( document && document . cookie ) {
735
+ // We delete the cookie by setting the expiration to a date/time in the past
736
+ document . cookie = COOKIE_KEY + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;' ;
737
+ window . location . href = '/login' ;
738
+ } else {
739
+ this . logService . warn ( 'Could not delete cookie because document and/or document.cookie is undefined' ) ;
740
+ }
741
+ } else {
742
+ this . logService . warn ( 'Could not log out because we could not find cookie' ) ;
743
+ }
744
+ } ) ) ;
745
+
722
746
const otherActions = this . getWebNavigationMenuItemActions ( ) . map ( action => {
723
747
const title = typeof action . item . title === 'string'
724
748
? action . item . title
0 commit comments