password update
This commit is contained in:
1 parent
1f0d0ed782
commit
99dde19847
2 files changed
+17
-1
No files matched your search
+2
-1
@@ -43,7 +43,8 @@
|
||||
</select>
|
||||
<button type="submit">Add User</button>
|
||||
</form>
|
||||
<!-- Manage Users -->
|
||||
|
||||
<!-- Manage Users -->
|
||||
<h3>Manage Users</h3>
|
||||
<select id="userDropdown" onchange="selectUserAction(this.value)">
|
||||
<option value="">-- Select a user --</option>
|
||||
|
||||
@@ -93,6 +93,7 @@ async function addNewUser() {
|
||||
const password = document.getElementById("newPassword").value
|
||||
const role = document.getElementById("newRole").value
|
||||
const msg = document.getElementById("userAddMessage")
|
||||
const hashPreview = document.getElementById("hashPreview")
|
||||
|
||||
if (!username || !password) {
|
||||
msg.textContent = "Please fill out all fields."
|
||||
@@ -100,13 +101,27 @@ async function addNewUser() {
|
||||
}
|
||||
|
||||
const hash = hashPassword(password)
|
||||
|
||||
// Live hash preview (optional visual confirmation for admin)
|
||||
if (hashPreview) {
|
||||
hashPreview.textContent = hash
|
||||
}
|
||||
|
||||
try {
|
||||
await saveUserToServer(username, hash, role)
|
||||
msg.textContent = `✅ User "${username}" added to server.`
|
||||
|
||||
// Clear fields after success
|
||||
document.getElementById("newUsername").value = ''
|
||||
document.getElementById("newPassword").value = ''
|
||||
if (hashPreview) hashPreview.textContent = '[auto]'
|
||||
|
||||
await loadUsers()
|
||||
displayUserDropdown()
|
||||
} catch (e) {
|
||||
msg.textContent = "❌ Failed to add user."
|
||||
console.error("Add user error:", e)
|
||||
}
|
||||
}
|
||||
|
||||
async function saveUserToServer(username, hash, role) {
|
||||
|
||||
Reference in new issue
Block a user