fix: connexion
This commit is contained in:
@ -4,14 +4,18 @@ import { client, navigateTo } from "../index.js";
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
if (client.isAuthentificate() == false)
|
||||
navigateTo("/home");
|
||||
this.setTitle("register");
|
||||
this.setTitle("Home");
|
||||
}
|
||||
|
||||
async getHtml() {
|
||||
if (await client.isAuthentificate() === false)
|
||||
{
|
||||
navigateTo("/login");
|
||||
return;
|
||||
}
|
||||
return `
|
||||
<h1>HOME</h1>
|
||||
<a href="/logout" class="nav__link" data-link>Logout</a>
|
||||
`;
|
||||
}
|
||||
}
|
@ -6,10 +6,9 @@ async function login()
|
||||
let username = document.getElementById("username").value;
|
||||
let password = document.getElementById("password").value;
|
||||
|
||||
let response = await client.login(username, password);
|
||||
let response_data = await response.json();
|
||||
let response_data = await client.login(username, password);
|
||||
|
||||
if (response_data == "user connected")
|
||||
if (response_data == null)
|
||||
{
|
||||
navigateTo("/home");
|
||||
return;
|
||||
@ -36,6 +35,11 @@ export default class extends AbstractView {
|
||||
|
||||
async postInit()
|
||||
{
|
||||
if (await client.isAuthentificate())
|
||||
{
|
||||
navigateTo("/home")
|
||||
return;
|
||||
}
|
||||
document.getElementById("button").onclick = login;
|
||||
}
|
||||
|
||||
|
13
frontend/static/js/views/accounts/LogoutView.js
Normal file
13
frontend/static/js/views/accounts/LogoutView.js
Normal file
@ -0,0 +1,13 @@
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
import AbstractView from "../AbstractView.js";
|
||||
|
||||
export default class extends AbstractView
|
||||
{
|
||||
constructor(params) {
|
||||
super(params);
|
||||
this.setTitle("Logout");
|
||||
if (client.logged)
|
||||
client.logout();
|
||||
navigateTo("/login")
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import AbstractView from "../AbstractView.js";
|
||||
import { client } from "../../index.js";
|
||||
import { client, navigateTo } from "../../index.js";
|
||||
|
||||
async function register()
|
||||
{
|
||||
@ -30,6 +30,11 @@ export default class extends AbstractView {
|
||||
|
||||
async postInit()
|
||||
{
|
||||
if (client.isAuthentificate())
|
||||
{
|
||||
navigateTo("/home")
|
||||
return;
|
||||
}
|
||||
document.getElementById("button").onclick = register;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user