Skip to content

Commit

Permalink
Change logout url
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Oct 6, 2024
1 parent ac8a016 commit d450528
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions packages/comment-widget/src/base-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class BaseForm extends LitElement {
.join('-')
.replaceAll(/-+/g, '-')}`;

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

get showCaptcha() {
Expand All @@ -98,25 +98,9 @@ export class BaseForm extends LitElement {
}

async handleLogout() {
if (window.confirm('确定要退出登录吗?')) {
if (window.confirm('点击确定将跳转至退出登录页面,请确保正在编辑的内容已保存。')) {
try {
const response = await fetch(`${this.baseUrl}/logout`, {
method: 'POST',
headers: {
'X-Xsrf-Token':
document.cookie
.split('; ')
.find((row) => row.startsWith('XSRF-TOKEN'))
?.split('=')[1] || '',
},
credentials: 'same-origin',
});

if (!response.ok) {
throw new Error('Failed to logout');
}

window.location.reload();
window.location.href = '/logout';
} catch (error) {
console.error('Failed to logout', error);
}
Expand Down

0 comments on commit d450528

Please sign in to comment.