mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-09 08:50:26 +00:00
316bd65296
* mws authentication * add more tests and permission checkers * add logic to ensure that only authenticated users' requests are handled * add custom login page * Implement user authentication as well as session handling * work on user operations authorization * add middleware to route handlers for bags & tiddlers routes * add feature that only returns the tiddlers and bags which the user has permission to access on index page * refactor auth routes & added user management page * fix Ci Test failure issue * fix users list page, add manage roles page * add commands and scripts to create new user & assign roles and permissions * resolved ci-test failure * add ACL permissions to bags & tiddlers on creation * fix comments and access control list bug * fix indentation issues * working on user profile edit * remove list users command & added support for database in server options * implement user profile update and password change feature * update plugin readme * implement command which triggers protected mode on the server * revert server-wide auth flag. Implement selective authorization * ACL management feature * Complete Access control list implementation * Added support to manage users' assigned role by admin * fix comments * fix comment * Add user profile management and account deletion functionality * add success and error message feedback for user profile operations * fix indentation issues * Add command to create admin user if none exists when the start command is executed * refactor annonymous user flow with create admin implementation * remove mws-add-user from start command
173 lines
5.2 KiB
Plaintext
173 lines
5.2 KiB
Plaintext
title: $:/plugins/tiddlywiki/multiwikiserver/templates/manage-user-account
|
|
|
|
<div class="user-profile-management">
|
|
<h2>Manage Account</h2>
|
|
<$set name="current-role-id" value={{{ [<user-role>jsonget[role_id]] }}}>
|
|
<form class="user-profile-form" action="/update-user-profile" method="POST">
|
|
<input type="hidden" name="userId" value={{{ [<user>jsonget[user_id]] }}}>
|
|
<div class="form-group">
|
|
<label for="username">Username:</label>
|
|
<input type="text" id="username" name="username" value={{{ [<user>jsonget[username]] }}} required />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Email:</label>
|
|
<input type="email" id="email" name="email" value={{{ [<user>jsonget[email]] }}} required />
|
|
</div>
|
|
<% if [<user-is-admin>match[yes]] %>
|
|
<div class="form-group">
|
|
<label for="role">Role:</label>
|
|
<select id="role" name="role" required>
|
|
<$list filter="[<all-roles>jsonindexes[]]" variable="role-index">
|
|
<$set name="role-id" value={{{ [<all-roles>jsonextract<role-index>jsonget[role_id]] }}}>
|
|
<option value=<<role-id>>>
|
|
<$text text={{{ [<all-roles>jsonextract<role-index>jsonget[role_name]] }}}/>
|
|
</option>
|
|
</$set>
|
|
</$list>
|
|
</select>
|
|
</div>
|
|
<% endif %>
|
|
<button type="submit" class="update-profile-btn">Update Profile</button>
|
|
<$list filter="[[$:/temp/mws/update-profile/]addsuffix<user-id>addsuffix[/error]!is[missing]]" variable="errorTiddler">
|
|
<div class="tc-error-message">
|
|
<$text text={{{[<errorTiddler>get[text]]}}}/>
|
|
</div>
|
|
</$list>
|
|
|
|
<$list filter="[[$:/temp/mws/update-profile/]addsuffix<user-id>addsuffix[/success]!is[missing]]" variable="successTiddler">
|
|
<div class="tc-success-message">
|
|
<$text text={{{[<successTiddler>get[text]]}}}/>
|
|
</div>
|
|
</$list>
|
|
</form>
|
|
</$set>
|
|
<% if [<user-is-admin>match[yes]] && [<is-current-user-profile>match[no]] %>
|
|
<hr />
|
|
<form class="user-profile-form" action="/delete-user-account" method="POST" onsubmit="return confirm('Are you sure you want to delete this user account? This action cannot be undone.');">
|
|
<input type="hidden" name="userId" value={{{ [<user>jsonget[user_id]] }}}>
|
|
<button type="submit" class="delete-account-btn">Delete User Account</button>
|
|
<$list filter="[[$:/temp/mws/delete-user/]addsuffix<user-id>addsuffix[/error]!is[missing]]" variable="deleteErrorTiddler">
|
|
<div class="tc-error-message">
|
|
<$text text={{{[<deleteErrorTiddler>get[text]]}}}/>
|
|
</div>
|
|
</$list>
|
|
</form>
|
|
<% endif %>
|
|
<% if [<is-current-user-profile>match[yes]] %>
|
|
<hr />
|
|
<h2>Change Password</h2>
|
|
<form class="user-profile-form" action="/change-user-password" method="POST">
|
|
<input type="hidden" name="userId" value={{{ [<user>jsonget[user_id]] }}}>
|
|
<div class="form-group">
|
|
<label for="new-password">New Password:</label>
|
|
<input type="password" id="new-password" name="newPassword" required />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="confirm-password">Confirm New Password:</label>
|
|
<input type="password" id="confirm-password" name="confirmPassword" required />
|
|
</div>
|
|
<button type="submit" class="update-password-btn">Change Password</button>
|
|
<$list filter="[[$:/temp/mws/change-password/]addsuffix<user-id>addsuffix[/error]!is[missing]]" variable="errorTiddler">
|
|
<div class="tc-error-message">
|
|
<$text text={{{[<errorTiddler>get[text]]}}}/>
|
|
</div>
|
|
</$list>
|
|
<$list filter="[[$:/temp/mws/change-password/]addsuffix<user-id>addsuffix[/success]!is[missing]]" variable="successTiddler">
|
|
<div class="tc-success-message">
|
|
<$text text={{{[<successTiddler>get[text]]}}}/>
|
|
</div>
|
|
</$list>
|
|
</form>
|
|
<% endif %>
|
|
</div>
|
|
|
|
<style>
|
|
.user-profile-management {
|
|
padding: 20px;
|
|
flex: 1;
|
|
}
|
|
|
|
.user-profile-management h2 {
|
|
font-size: 1.2rem;
|
|
color: #3498db;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.user-profile-form {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.user-profile-form .form-group {
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.user-profile-form label {
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
font-weight: bold;
|
|
color: #555;
|
|
}
|
|
|
|
.user-profile-form input {
|
|
width: 100%;
|
|
padding: 0.5rem;
|
|
border: 1px solid #ccc;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.update-profile-btn,
|
|
.update-password-btn {
|
|
background: #3498db;
|
|
color: #fff;
|
|
border: none;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.update-password-btn {
|
|
background: #00796b;
|
|
}
|
|
|
|
.update-profile-btn:hover {
|
|
background: #2980b9;
|
|
}
|
|
|
|
.update-password-btn:hover {
|
|
background: #00695c;
|
|
}
|
|
|
|
.user-profile-form select {
|
|
width: 100%;
|
|
padding: 0.5rem;
|
|
border: 1px solid #ccc;
|
|
border-radius: 4px;
|
|
background-color: white;
|
|
}
|
|
|
|
.delete-account-btn {
|
|
background: #e74c3c;
|
|
color: #fff;
|
|
border: none;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 1rem;
|
|
width: 100%;
|
|
}
|
|
|
|
.delete-account-btn:hover {
|
|
background: #c0392b;
|
|
}
|
|
|
|
.tc-error-message {
|
|
color: red;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.tc-success-message {
|
|
color: green;
|
|
font-weight: bold;
|
|
}
|
|
</style> |