From b5c617866ac688e052a14fd8950926ee5c669c47 Mon Sep 17 00:00:00 2001 From: webplusai Date: Mon, 30 Dec 2024 18:19:10 +0000 Subject: [PATCH] #8868 add login button in header for guest user --- .../modules/routes/handlers/get-index.js | 1 + .../modules/routes/handlers/manage-user.js | 1 + .../multiwikiserver/templates/mws-header.tid | 46 +++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-index.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-index.js index 47aadda25..1b5dc96fe 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-index.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-index.js @@ -50,6 +50,7 @@ exports.handler = function(request,response,state) { "user-is-admin": state.authenticatedUser && state.authenticatedUser.isAdmin ? "yes" : "no", "first-guest-user": state.firstGuestUser ? "yes" : "no", "show-anon-config": state.showAnonConfig ? "yes" : "no", + "user-is-logged-in": !!state.authenticatedUser ? "yes" : "no", "user": JSON.stringify(state.authenticatedUser), "has-profile-access": !!state.authenticatedUser ? "yes" : "no" }}); diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/manage-user.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/manage-user.js index 5b1ecc383..cada04b83 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/manage-user.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/manage-user.js @@ -91,6 +91,7 @@ exports.handler = function(request,response,state) { "username": state.authenticatedUser ? state.authenticatedUser.username : state.firstGuestUser ? "Anonymous User" : "Guest", "user-is-admin": state.authenticatedUser && state.authenticatedUser.isAdmin ? "yes" : "no", "user-id": user_id, + "user-is-logged-in": !!state.authenticatedUser ? "yes" : "no", "has-profile-access": !!state.authenticatedUser ? "yes" : "no" } }); diff --git a/plugins/tiddlywiki/multiwikiserver/templates/mws-header.tid b/plugins/tiddlywiki/multiwikiserver/templates/mws-header.tid index 0d45a2f5f..93c6f7e0d 100644 --- a/plugins/tiddlywiki/multiwikiserver/templates/mws-header.tid +++ b/plugins/tiddlywiki/multiwikiserver/templates/mws-header.tid @@ -27,16 +27,25 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header - <% elseif [match[yes]] %> - <$set name="userId" value={{{ [jsonget[user_id]] }}}> - addprefix[/admin/users/]] }}}> - - - <% endif %> -
- -
+ <% if [match[yes]] %> + <%if [match[no]] %> + <%if [match[no]] %> + <$set name="userId" value={{{ [jsonget[user_id]] }}}> + addprefix[/admin/users/]] }}}> + + + + <% endif %> + <% endif %> + <% endif %> + <% if [match[yes]] %> +
+ +
+ <% else %> + + <% endif %> @@ -82,6 +91,25 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header background-color: #d32f2f; } +.mws-login-btn { + margin-left: 5px; + background-color: #4caf50; + color: white; + border: none; + cursor: pointer; + text-decoration: none; + height: 27px; + width: 62px; + text-align: center; + display: flex; + align-items: center; + justify-content: center; +} + +.mws-login-btn:hover { + background-color: #388e3c; +} + .mws-admin-dropdown { position: relative; display: inline-block;