Finally done!

This commit is contained in:
Astatin3
2024-02-20 10:25:34 -07:00
parent ef75228361
commit bd77a9fcc5
24 changed files with 645 additions and 215 deletions
Regular → Executable
+44 -25
View File
@@ -1,6 +1,7 @@
<main class="container">
<h3>User Settings</h3>
<p>Sessions</p>
<div id="details"></div>
<h4>Sessions</h4>
<table role="grid">
<thead>
<tr>
@@ -8,7 +9,7 @@
<th scope="col">Address</th>
<th scope="col">Path</th>
<th scope="col">Expires</th>
<th scope="col">Remove</th>
<th scope="col">Manage</th>
</tr>
</thead>
<tbody id="sessionTable"></tbody>
@@ -26,12 +27,12 @@
}
function logout() {
window.sendRaw('logout', {})
window.send('logout', {})
utils.setCookie('session', '')
}
function unauthClient(id) {
window.sendRaw('unauth', id)
function unauthSession(id) {
window.send('unauth', id)
}
function changePassword() {
@@ -41,16 +42,45 @@
const textColor = 'text-white'
const title = "Change password"
utils.modal(elem, 'document.body',bgcolor, header, textColor, title, `
<input type="password" placeholder="Old Password"></input>
<input type="password" placeholder="New Password"></input>
<input type="password" placeholder="Retype new Password"></input>
<button>Submit</button>`)
utils.modal(elem, bgcolor, header, textColor, title, `
<input id="oldPassword" type="password" placeholder="Old Password"></input>
<input autocomplete="new-password" id="password1" type="password" placeholder="New Password"></input>
<input autocomplete="new-password" id="password2" type="password" placeholder="Retype new Password"></input>
<button onclick="passwordSubmit();document.body.removeChild(this.parentElement.parentElement)">Submit</button>`)
}
function passwordSubmit() {
const oldPassword = utils.getel("oldPassword").value
const password1 = utils.getel("password1").value
const password2 = utils.getel("password2").value
if(oldPassword == "" || password1 == "" || password2 == ""){
utils.popupError("Error", "Please fill out all areas of form")
return
}else if(password1 != password2){
utils.popupError("Error", "Passwords don't match")
return
}
client.send("passwordChangeRequest", {
id: authClient.id,
old: utils.sha256(oldPassword),
new: utils.sha256(password1)
})
}
window.main = ()=>{
const sessionTable = document.getElementById('sessionTable')
window.addListener("reauth", (data)=>{
let details = utils.getel('details')
details.innerHTML += "<p>Username: " + authClient.username + "</p>"
details.innerHTML += "<p>Groups: " + authClient.permGroups.join(", ") + "</p>"
details.innerHTML += "<p>Created: " + utils.formatTime(authClient.accountCreated) + "</p>"
details.innerHTML += "<p>Password Updated: " + utils.formatTime(authClient.passwordUpdated) + "</p>"
})
window.addListener("sessions", (data)=>{
sessions = data.data
@@ -62,25 +92,14 @@
<td>${sessions[i].address}</td>
<td>${sessions[i].currentPage}</td>
<td>${utils.formatTime(sessions[i].timeout)}</td>
<td><a href="#" onclick="promptUnauth('${sessions[i].clientid}')">Logout</a></td>
<td><a href="#" onclick="unauthSession('${sessions[i].clientid}')">Logout</a></td>
</tr>
`
}
sessionTable.innerHTML = html
utils.getel('sessionTable').innerHTML = html
})
}
</script>
<!--
#################################################
New Credentials - THESE ONLY WILL BE PRINTED ONCE
########
Username: User
Password: 67FFCdfb9dB827fB
########
Username: Admin
Password: eB0BB402900DfE5A
#################################################
-->
</script>