Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
1a91be96
C
code-server
项目概览
myhjmzy
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
1a91be96
编写于
3月 23, 2021
作者:
J
Joe Previte
提交者:
GitHub
3月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'main' into dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-4.19.0
上级
3ab625f8
947dd856
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
2 deletion
+85
-2
lib/vscode/src/vs/server/common/cookie.ts
lib/vscode/src/vs/server/common/cookie.ts
+3
-0
lib/vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.ts
...src/vs/workbench/browser/parts/titlebar/menubarControl.ts
+27
-2
test/e2e/logout.test.ts
test/e2e/logout.test.ts
+55
-0
未找到文件。
lib/vscode/src/vs/server/common/cookie.ts
0 → 100644
浏览文件 @
1a91be96
export
enum
Cookie
{
Key
=
'
key
'
,
}
lib/vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.ts
浏览文件 @
1a91be96
...
...
@@ -9,7 +9,7 @@ import { registerThemingParticipant, IThemeService } from 'vs/platform/theme/com
import
{
MenuBarVisibility
,
getTitleBarStyle
,
IWindowOpenable
,
getMenuBarVisibility
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IAction
,
Action
,
SubmenuAction
,
Separator
}
from
'
vs/base/common/actions
'
;
import
{
addDisposableListener
,
Dimension
,
EventType
}
from
'
vs/base/browser/dom
'
;
import
{
addDisposableListener
,
Dimension
,
EventType
,
getCookieValue
}
from
'
vs/base/browser/dom
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
isMacintosh
,
isWeb
,
isIOS
,
isNative
}
from
'
vs/base/common/platform
'
;
import
{
IConfigurationService
,
IConfigurationChangeEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -38,6 +38,8 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IsWebContext
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
Cookie
}
from
'
vs/server/common/cookie
'
;
export
abstract
class
MenubarControl
extends
Disposable
{
...
...
@@ -312,7 +314,8 @@ export class CustomMenubarControl extends MenubarControl {
@
IThemeService
private
readonly
themeService
:
IThemeService
,
@
IWorkbenchLayoutService
private
readonly
layoutService
:
IWorkbenchLayoutService
,
@
IHostService
protected
readonly
hostService
:
IHostService
,
@
ICommandService
commandService
:
ICommandService
@
ICommandService
commandService
:
ICommandService
,
@
ILogService
private
readonly
logService
:
ILogService
)
{
super
(
menuService
,
workspacesService
,
contextKeyService
,
keybindingService
,
configurationService
,
labelService
,
updateService
,
storageService
,
notificationService
,
preferencesService
,
environmentService
,
accessibilityService
,
hostService
,
commandService
);
...
...
@@ -711,6 +714,28 @@ export class CustomMenubarControl extends MenubarControl {
webNavigationActions
.
pop
();
}
webNavigationActions
.
push
(
new
Action
(
'
logout
'
,
localize
(
'
logout
'
,
"
Log out
"
),
undefined
,
true
,
async
(
event
?:
MouseEvent
)
=>
{
const
COOKIE_KEY
=
Cookie
.
Key
;
const
loginCookie
=
getCookieValue
(
COOKIE_KEY
);
this
.
logService
.
info
(
'
Logging out of code-server
'
);
if
(
loginCookie
)
{
this
.
logService
.
info
(
`Removing cookie under
${
COOKIE_KEY
}
`
);
if
(
document
&&
document
.
cookie
)
{
// We delete the cookie by setting the expiration to a date/time in the past
document
.
cookie
=
COOKIE_KEY
+
'
=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;
'
;
window
.
location
.
href
=
'
/login
'
;
}
else
{
this
.
logService
.
warn
(
'
Could not delete cookie because document and/or document.cookie is undefined
'
);
}
}
else
{
this
.
logService
.
warn
(
'
Could not log out because we could not find cookie
'
);
}
}));
return
webNavigationActions
;
}
...
...
test/e2e/logout.test.ts
0 → 100644
浏览文件 @
1a91be96
import
{
chromium
,
Page
,
Browser
,
BrowserContext
}
from
"
playwright
"
import
{
CODE_SERVER_ADDRESS
,
PASSWORD
,
E2E_VIDEO_DIR
}
from
"
../utils/constants
"
describe
(
"
logout
"
,
()
=>
{
let
browser
:
Browser
let
page
:
Page
let
context
:
BrowserContext
beforeAll
(
async
()
=>
{
browser
=
await
chromium
.
launch
()
context
=
await
browser
.
newContext
({
recordVideo
:
{
dir
:
E2E_VIDEO_DIR
},
})
})
afterAll
(
async
()
=>
{
await
browser
.
close
()
})
beforeEach
(
async
()
=>
{
page
=
await
context
.
newPage
()
})
afterEach
(
async
()
=>
{
await
page
.
close
()
// Remove password from local storage
await
context
.
clearCookies
()
})
it
(
"
should be able login and logout
"
,
async
()
=>
{
await
page
.
goto
(
CODE_SERVER_ADDRESS
)
// Type in password
await
page
.
fill
(
"
.password
"
,
PASSWORD
)
// Click the submit button and login
await
page
.
click
(
"
.submit
"
)
// See the editor
const
codeServerEditor
=
await
page
.
isVisible
(
"
.monaco-workbench
"
)
expect
(
codeServerEditor
).
toBeTruthy
()
// Click the Application menu
await
page
.
click
(
"
[aria-label='Application Menu']
"
)
// See the Log out button
const
logoutButton
=
"
a.action-menu-item span[aria-label='Log out']
"
expect
(
await
page
.
isVisible
(
logoutButton
))
await
page
.
hover
(
logoutButton
)
await
page
.
click
(
logoutButton
)
// it takes a couple seconds to navigate
await
page
.
waitForTimeout
(
2000
)
const
currentUrl
=
page
.
url
()
expect
(
currentUrl
).
toBe
(
`
${
CODE_SERVER_ADDRESS
}
/login`
)
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录