Skip to content
Snippets Groups Projects
Commit 1441e6e5 authored by Nicolas PAGNY's avatar Nicolas PAGNY
Browse files

Add redirection to empty login page for not logged users

parent ab01eef2
No related branches found
No related tags found
No related merge requests found
export async function mount(where) {
const loginComponent = new Login();
await loginComponent.mount(where);
}
class Login {
constructor() {
}
async mount(mountpoint) {
document.getElementById(mountpoint).innerHTML = /* HTML */ "Empty page"
}
}
import * as Auth from "/components/auth/auth.js"; import * as Auth from "/components/auth/auth.js";
import * as Matcher from "/components/matcher/matcher.js"; import * as Matcher from "/components/matcher/matcher.js";
import * as Info from "/components/info/info.js"; import * as Info from "/components/info/info.js";
import * as Login from "./components/login/login.js";
const mountPoint = document.getElementById("main"); const mountPoint = document.getElementById("main");
let user = {}; let user = {};
...@@ -11,39 +12,47 @@ document.addEventListener("DOMContentLoaded", async () => { ...@@ -11,39 +12,47 @@ document.addEventListener("DOMContentLoaded", async () => {
}); });
async function navigate() { async function navigate() {
switch (location.pathname) { console
case "/auth": if(user == undefined){
load(mountPoint, async function () { console.log("test")
await Auth.mount("main"); load(mountPoint, async function() {
}); await Login.mount("main");
break; })
case "/matcher": }else{
load(mountPoint, async function () { switch (location.pathname) {
await Matcher.mount("main"); case "/auth":
}); load(mountPoint, async function () {
break; await Auth.mount("main");
case "/mandatecreated": });
load(mountPoint, async function () { break;
await Info.mount("main", "Le mandat a été créé avec succès !"); case "/matcher":
}); load(mountPoint, async function () {
break; await Matcher.mount("main");
case "/callback": });
// Redirect to server callback according to cookie break;
try { case "/mandatecreated":
const callbackRoute = document.cookie load(mountPoint, async function () {
.split("; ") await Info.mount("main", "Le mandat a été créé avec succès !");
.find((row) => row.startsWith("callbackRoute=")) });
.split("=")[1]; break;
if (callbackRoute != "" && callbackRoute != null) { case "/callback":
location.pathname = callbackRoute; // Redirect to server callback according to cookie
try {
const callbackRoute = document.cookie
.split("; ")
.find((row) => row.startsWith("callbackRoute="))
.split("=")[1];
if (callbackRoute != "" && callbackRoute != null) {
location.pathname = callbackRoute;
}
} catch (e) {
console.error("no callback route was gotten from the cookie");
} }
} catch (e) { break;
console.error("no callback route was gotten from the cookie"); default:
} location.pathname = "auth";
break; break;
default: }
location.pathname = "auth";
break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment