Skip to content

Commit

Permalink
#8868 add login button in header for guest user (#8874)
Browse files Browse the repository at this point in the history
  • Loading branch information
webplusai authored Jan 8, 2025
1 parent 19e341c commit c7dc21a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
});
Expand Down
46 changes: 37 additions & 9 deletions plugins/tiddlywiki/multiwikiserver/templates/mws-header.tid
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,25 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header
</form>
</div>
</div>
<% elseif [<has-profile-access>match[yes]] %>
<$set name="userId" value={{{ [<user>jsonget[user_id]] }}}>
<a href={{{ [<userId>addprefix[/admin/users/]] }}}>
<button class="mws-profile-btn">Profile</button>
</a>
</$set>
<% endif %>
<form action="/logout" method="post" class="mws-logout-form">
<input type="submit" value="Logout" class="mws-logout-button"/>
</form>
<% if [<user-is-logged-in>match[yes]] %>
<%if [<first-guest-user>match[no]] %>
<%if [<user-is-admin>match[no]] %>
<$set name="userId" value={{{ [<user>jsonget[user_id]] }}}>
<a href={{{ [<userId>addprefix[/admin/users/]] }}}>
<button class="mws-profile-btn">Profile</button>
</a>
</$set>
<% endif %>
<% endif %>
<% endif %>
<% if [<user-is-logged-in>match[yes]] %>
<form action="/logout" method="post" class="mws-logout-form">
<input type="submit" value="Logout" class="mws-logout-button"/>
</form>
<% else %>
<a class="mws-login-btn" href="/login">Login</a>
<% endif %>
</div>
</div>

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c7dc21a

Please sign in to comment.