mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-02 16:43:00 +00:00
Fix issue with default user role on create, profile navigation issue (#8761)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user