Skip to content

Commit

Permalink
First attempt at making a logout feature
Browse files Browse the repository at this point in the history
  • Loading branch information
harshil05133 committed Feb 18, 2025
1 parent 96234df commit f5598fd
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion settings.json.docker
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@
"right": [
["importexport", "timeslider", "savedrevision"],
["settings", "embed"],
["showusers", "gohome"]
["showusers", "gohome", "logout"]
],
"timeslider": [
["timeslider_export", "timeslider_returnToPad"]
Expand Down
2 changes: 1 addition & 1 deletion settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
"right": [
["importexport", "timeslider", "savedrevision"],
["settings", "embed"],
["showusers", "gohome"]
["showusers", "gohome", "logout"]
],
"timeslider": [
["timeslider_export", "timeslider_returnToPad"]
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/node/utils/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ exports.toolbar = {
right: [
['importexport', 'timeslider', 'savedrevision'],
['settings', 'embed'],
['showusers', 'gohome'],
['showusers', 'gohome', 'logout'],
],
timeslider: [
['timeslider_export', 'timeslider_settings', 'timeslider_returnToPad'],
Expand Down
6 changes: 6 additions & 0 deletions src/node/utils/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions src/static/css/pad/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
11 changes: 11 additions & 0 deletions src/static/js/pad_editbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
7 changes: 6 additions & 1 deletion ui/pad.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@
<li data-type="button" data-key="embed"><a class="grouped-right" data-l10n-id="pad.toolbar.embed.title"><button class=" buttonicon buttonicon-embed" data-l10n-id="pad.toolbar.embed.title"></button></a></li><li class="separator"></li><li data-type="button" data-key="showusers"><a class="" data-l10n-id="pad.toolbar.showusers.title"><button class=" buttonicon buttonicon-showusers" data-l10n-id="pad.toolbar.showusers.title"></button></a></li>
<li data-type="button" data-key="gohome">
<a class="grouped_middle" data-l10n-id="pad.toolbar.gohome.title">
<button class="buttonicon buttonicon-gohome" data-l10n-id="pad.toolbar.gohome.title"></button>
<button class="buttonicon buttonicon-gohome" data-l10n-id="pad.toolbar.gohome.title" title="Go Home"></button>
</a>
</li>
<li data-type="button" data-key="logout">
<a class="grouped-right" data-l10n-id="pad.toolbar.logout.title">
<button class="buttonicon buttonicon-logout" data-l10n-id="pad.toolbar.logout.title" title="Logout"></button>
</a>
</li>

Expand Down

0 comments on commit f5598fd

Please sign in to comment.