Skip to content

Commit e7a5275

Browse files
committed
Add authed context key
1 parent 9fe459a commit e7a5275

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/vscode/src/vs/server/browser/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { URI } from 'vs/base/common/uri';
33
import { Options } from 'vs/ipc';
44
import { localize } from 'vs/nls';
55
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
6+
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
67
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
78
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
89
import { ILogService } from 'vs/platform/log/common/log';
@@ -173,6 +174,10 @@ export const initialize = async (services: ServiceCollection): Promise<void> =>
173174
if (theme) {
174175
localStorage.setItem('colorThemeData', theme);
175176
}
177+
178+
// Use to show or hide logout commands and menu options.
179+
const contextKeyService = (services.get(IContextKeyService) as IContextKeyService);
180+
contextKeyService.createKey('code-server.authed', options.authed);
176181
};
177182

178183
export interface Query {

src/node/routes/vscode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Request, Router } from "express"
33
import { promises as fs } from "fs"
44
import * as path from "path"
55
import qs from "qs"
6+
import * as ipc from "../../../typings/ipc"
67
import { Emitter } from "../../common/emitter"
78
import { HttpCode, HttpError } from "../../common/http"
89
import { getFirstString } from "../../common/util"
@@ -39,12 +40,13 @@ router.get("/", async (req, res) => {
3940
options.productConfiguration.codeServerVersion = version
4041

4142
res.send(
42-
replaceTemplates(
43+
replaceTemplates<ipc.Options>(
4344
req,
4445
// Uncomment prod blocks if not in development. TODO: Would this be
4546
// better as a build step? Or maintain two HTML files again?
4647
commit !== "development" ? content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "") : content,
4748
{
49+
authed: req.args.auth !== "none",
4850
disableTelemetry: !!req.args["disable-telemetry"],
4951
disableUpdateCheck: !!req.args["disable-update-check"],
5052
},

typings/ipc.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* The second is a symlink to the first.
77
*/
88
export interface Options {
9+
authed: boolean
910
base: string
1011
disableTelemetry: boolean
1112
disableUpdateCheck: boolean

0 commit comments

Comments
 (0)