mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Fix issue with default user role on create, profile navigation issue (#8761)
This commit is contained in:
parent
d9256707f4
commit
4dc2486d4b
@ -45,6 +45,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-annon-config": state.showAnonConfig ? "yes" : "no",
|
||||
"user": JSON.stringify(state.authenticatedUser),
|
||||
}});
|
||||
response.write(html);
|
||||
response.end();
|
||||
|
@ -86,6 +86,7 @@ exports.handler = function(request,response,state) {
|
||||
"user-initials": user.username.split(" ").map(name => name[0]).join(""),
|
||||
"user-role": JSON.stringify(userRole),
|
||||
"all-roles": JSON.stringify(allRoles),
|
||||
"first-guest-user": state.firstGuestUser ? "yes" : "no",
|
||||
"is-current-user-profile": state.authenticatedUser && state.authenticatedUser.user_id === $tw.utils.parseInt(user_id, 10) ? "yes" : "no",
|
||||
"username": state.authenticatedUser ? state.authenticatedUser.username : state.firstGuestUser ? "Annonymous User" : "Guest",
|
||||
"user-is-admin": state.authenticatedUser && state.authenticatedUser.isAdmin ? "yes" : "no",
|
||||
|
@ -78,6 +78,12 @@ exports.handler = function(request, response, state) {
|
||||
response.end();
|
||||
return;
|
||||
} else {
|
||||
// assign role to user
|
||||
const roles = sqlTiddlerDatabase.listRoles();
|
||||
const roleId = roles.find(role => role.role_name.toUpperCase() !== "ADMIN")?.role_id;
|
||||
if (roleId) {
|
||||
sqlTiddlerDatabase.addRoleToUser(userId, roleId);
|
||||
}
|
||||
response.writeHead(302, {"Location": "/admin/users/"+userId});
|
||||
response.end();
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header
|
||||
|
||||
<div class="mws-header">
|
||||
<h1><$text text=<<page-title>>/></h1>
|
||||
<h1>
|
||||
<a href="/">
|
||||
<span class="mws-logo">🏠</span>
|
||||
</a>
|
||||
<span class="divider">|</span>
|
||||
<$text text=<<page-title>>/>
|
||||
</h1>
|
||||
<div class="mws-user-info">
|
||||
<span>Hello, <$text text=<<username>>/></span>
|
||||
<% if [<user-is-admin>match[yes]] %>
|
||||
@ -16,9 +22,11 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header
|
||||
</div>
|
||||
</div>
|
||||
<% elseif [<username>!match[Guest]]+[<first-guest-user>match[no]] %>
|
||||
<a href={{{ [<user>jsonget[user_id]addprefix[/admin/users/]] }}}>
|
||||
<button class="mws-profile-btn">Profile</button>
|
||||
</a>
|
||||
<$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"/>
|
||||
@ -36,6 +44,17 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.mws-header h1 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.mws-header h1 .divider {
|
||||
font-size: 16px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.mws-user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -126,4 +145,8 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/mws-header
|
||||
.mws-admin-form-button:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
</style>
|
||||
|
||||
.mws-logo {
|
||||
font-size: 24px;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user