| 12345678910111213141516171819202122232425262728293031323334 |
- export default {
- form: null,
- display(){
- if(this.form === null){
- this.form = document.querySelector("#loginPage form");
- this.form.addEventListener("submit", (event)=>{
- this.submit(event);
- });
- }
- document.getElementById("loginPageEmail").focus();
- },
- async submit(event){
- event.preventDefault();
- const body = {
- email: document.getElementById("loginPageEmail").value,
- password: document.getElementById("loginPagePassword").value
- };
- const response = await fetch("/login", {
- method: "POST",
- headers: {"Content-Type": "application/json"},
- body: JSON.stringify(body)
- });
-
- const data = await response.json();
- if(!response.ok) return notify("error", data.msg);
- openPage("dashboard");
- }
- }
|