added password changes
This commit is contained in:
parent
f6f9c8343b
commit
fc87764782
41
css/changePW.css
Normal file
41
css/changePW.css
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
* {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
text-align: center;
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 5px solid black;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 5%;
|
||||||
|
padding-top: 1%;
|
||||||
|
background-color: darkgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 19px;
|
||||||
|
background-color: purple;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 20px;
|
||||||
|
text-align: center;
|
||||||
|
background-color: darkgray;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: inline-block;
|
||||||
|
width: 150px;
|
||||||
|
text-align: right;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
52
views/changePW.html
Normal file
52
views/changePW.html
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Change Password</title>
|
||||||
|
<link rel="stylesheet" href="/css/changePW.css">
|
||||||
|
<script type="text/javascript">window.post = function(url, data) {return fetch(url, {method: "POST", headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)});}</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1 id="username">Current User: USER</h1>
|
||||||
|
<label for="currentPW">Current Password:</label>
|
||||||
|
<input id="currentPW" placeholder="Current Password" autofocus type="password">
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<label for="newPW">New Password:</label>
|
||||||
|
<input id="newPW" placeholder="New Password" type="password">
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button id="submit">Change Password</button>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<span id="response"></span>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
async function setUser() {
|
||||||
|
let user = await (await fetch("/api/getuser")).json()
|
||||||
|
//user["username"],user["error"]
|
||||||
|
if(user["username"])document.getElementById("username").innerText = `Current User: ${user["username"]}`
|
||||||
|
if(user["error"])document.getElementById("username").innerText = `Error: ${user["error"]}`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setUser()
|
||||||
|
|
||||||
|
document.getElementById("submit").addEventListener("click",async function(){
|
||||||
|
if(window.confirm("Are you sure that you want to change your Password?")){
|
||||||
|
let re = await (await post("/api/changePW",{"currentPW":document.getElementById("currentPW").value,"newPW":document.getElementById("newPW").value})).json()
|
||||||
|
document.getElementById("response").innerText = re["error"] || re["success"]
|
||||||
|
document.getElementById("response").style="color:green"
|
||||||
|
if(re["error"]) {
|
||||||
|
document.getElementById("response").style="color:red"
|
||||||
|
}
|
||||||
|
document.getElementById("currentPW").value = ""
|
||||||
|
document.getElementById("newPW").value = ""
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user