Initial
This commit is contained in:
16
public/login.js
Normal file
16
public/login.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { postData } from "./client.js";
|
||||
|
||||
const loginForm = document.getElementById("loginForm");
|
||||
|
||||
if (loginForm) loginForm.onsubmit = async e => {
|
||||
e.preventDefault();
|
||||
let resultObject = await postData("/login", {
|
||||
username: document.getElementById("logUser").value,
|
||||
password: document.getElementById("logPass").value
|
||||
});
|
||||
alert(resultObject.message);
|
||||
if (resultObject.success) {
|
||||
window.location.href = "home.html"
|
||||
localStorage.setItem("token", resultObject.token);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user