Skip to content

Commit 3ab7d2f

Browse files
authored
refactor: change login url (#157)
Halo 2.20 将提供新的登录入口(/login),此 PR 用于适配新的登录地址。 See more: halo-dev/halo#6488 /kind improvement ```release-note 适配 Halo 2.20 的新登录入口。 ```
1 parent 326608c commit 3ab7d2f

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

packages/comment-widget/src/base-form.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class BaseForm extends LitElement {
7171
.join('-')
7272
.replaceAll(/-+/g, '-')}`;
7373

74-
return `/console/login?redirect_uri=${encodeURIComponent(window.location.href + parentDomId)}`;
74+
return `/login?redirect_uri=${encodeURIComponent(window.location.pathname + parentDomId)}`;
7575
}
7676

7777
get showCaptcha() {
@@ -98,25 +98,9 @@ export class BaseForm extends LitElement {
9898
}
9999

100100
async handleLogout() {
101-
if (window.confirm('确定要退出登录吗?')) {
101+
if (window.confirm('点击确定将跳转至退出登录页面,请确保正在编辑的内容已保存。')) {
102102
try {
103-
const response = await fetch(`${this.baseUrl}/logout`, {
104-
method: 'POST',
105-
headers: {
106-
'X-Xsrf-Token':
107-
document.cookie
108-
.split('; ')
109-
.find((row) => row.startsWith('XSRF-TOKEN'))
110-
?.split('=')[1] || '',
111-
},
112-
credentials: 'same-origin',
113-
});
114-
115-
if (!response.ok) {
116-
throw new Error('Failed to logout');
117-
}
118-
119-
window.location.reload();
103+
window.location.href = '/logout';
120104
} catch (error) {
121105
console.error('Failed to logout', error);
122106
}

src/main/resources/plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
"store.halo.run/app-id": "app-YXyaD"
99
spec:
1010
enabled: true
11-
requires: ">=2.17.0"
11+
requires: ">=2.20.0"
1212
author:
1313
name: Halo
1414
website: https://github.com/halo-dev

0 commit comments

Comments
 (0)