diff --git a/frontend/static/js/views/accounts/LoginView.js b/frontend/static/js/views/accounts/LoginView.js
index ce3df84..e545358 100644
--- a/frontend/static/js/views/accounts/LoginView.js
+++ b/frontend/static/js/views/accounts/LoginView.js
@@ -1,5 +1,5 @@
import AbstractView from "../AbstractView.js";
-import { client } from "../../index.js";
+import { client, navigateTo } from "../../index.js";
async function login()
{
@@ -8,7 +8,13 @@ async function login()
let response = await client.login(username, password);
let response_data = await response.json();
-
+
+ if (response_data == "user connected")
+ {
+ navigateTo("/home");
+ return;
+ }
+
["username", "user", "password"].forEach(error_field => {
let error_display = document.getElementById(`error_${error_field}`);
if (error_display != null)
@@ -26,11 +32,11 @@ export default class extends AbstractView {
constructor(params) {
super(params);
this.setTitle("Login");
- document.body.addEventListener("click", e => {
- e.preventDefault();
- if (e.target.type == "button")
- login();
- });
+ }
+
+ async postInit()
+ {
+ document.getElementById("button").onclick = login;
}
async getHtml() {
@@ -42,7 +48,7 @@ export default class extends AbstractView {
-
+
Register
diff --git a/frontend/static/js/views/accounts/RegisterView.js b/frontend/static/js/views/accounts/RegisterView.js
index d048321..e5c7c1f 100644
--- a/frontend/static/js/views/accounts/RegisterView.js
+++ b/frontend/static/js/views/accounts/RegisterView.js
@@ -26,11 +26,11 @@ export default class extends AbstractView {
constructor(params) {
super(params);
this.setTitle("register");
- document.body.addEventListener("click", e => {
- e.preventDefault();
- if (e.target.type == "button")
- register();
- });
+ }
+
+ async postInit()
+ {
+ document.getElementById("button").onclick = register;
}
async getHtml() {
@@ -42,7 +42,7 @@ export default class extends AbstractView {
-
+
Login