diff --git a/settings.json.docker b/settings.json.docker index 3d04dadf7..0cad69bf4 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -644,7 +644,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers", "gohome"] + ["showusers", "gohome", "logout"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/settings.json.template b/settings.json.template index 94ed5ed88..b69a90137 100644 --- a/settings.json.template +++ b/settings.json.template @@ -643,7 +643,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers", "gohome"] + ["showusers", "gohome", "logout"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/src/locales/en.json b/src/locales/en.json index 69de63564..6428f4b92 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -55,6 +55,7 @@ "pad.toolbar.embed.title": "Share and Embed this pad", "pad.toolbar.showusers.title": "Show the users on this pad", "pad.toolbar.gohome.title": "Go Home", + "pad.toolbar.logout.title": "Logout", "pad.colorpicker.save": "Save", diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts index f06b101d2..c906fdf97 100644 --- a/src/node/utils/Settings.ts +++ b/src/node/utils/Settings.ts @@ -247,7 +247,7 @@ exports.toolbar = { right: [ ['importexport', 'timeslider', 'savedrevision'], ['settings', 'embed'], - ['showusers', 'gohome'], + ['showusers', 'gohome', 'logout'], ], timeslider: [ ['timeslider_export', 'timeslider_settings', 'timeslider_returnToPad'], diff --git a/src/node/utils/toolbar.ts b/src/node/utils/toolbar.ts index 74a051cf1..ea48580d3 100644 --- a/src/node/utils/toolbar.ts +++ b/src/node/utils/toolbar.ts @@ -247,6 +247,12 @@ module.exports = { class: 'buttonicon buttonicon-gohome', }, + logout:{ + command: 'logout', + localizationId: 'pad.toolbar.logout.title', + class: 'buttonicon buttonicon-logout', + }, + timeslider_export: { command: 'import_export', localizationId: 'timeslider.toolbar.exportlink.title', diff --git a/src/static/css/pad/icons.css b/src/static/css/pad/icons.css index ffe6b681a..d703d9d5c 100644 --- a/src/static/css/pad/icons.css +++ b/src/static/css/pad/icons.css @@ -77,6 +77,9 @@ .buttonicon-gohome:before { content: "\e80b"; /* Assuming \e80b is the Unicode for the home icon */ } +.buttonicon-logout:before { + content: "\e800"; /* Assuming \e800 is the Unicode for the logout icon */ +} .buttonicon-savedRevision:before { content: "\e856"; } diff --git a/src/static/js/pad_editbar.ts b/src/static/js/pad_editbar.ts index a3097c4d7..b73af9710 100644 --- a/src/static/js/pad_editbar.ts +++ b/src/static/js/pad_editbar.ts @@ -392,6 +392,17 @@ exports.padeditbar = new class { window.location.href = '/'; }); + this.registerCommand('logout', () => { + console.log('Logout button clicked'); + // Clear session or authentication token + fetch('/logout', { method: 'POST' }) + .then(response => { + if (response.ok) { + window.location.href = '/'; // Redirect to the home page + } + }); + }); + this.registerCommand('embed', () => { this.setEmbedLinks(); this.toggleDropDown('embed'); diff --git a/ui/pad.html b/ui/pad.html index 619dca8c8..baa3a0b3f 100644 --- a/ui/pad.html +++ b/ui/pad.html @@ -79,7 +79,12 @@
  • - + + +
  • +
  • + +