front: redirect to last visited page after login

This commit is contained in:
AdrienLSH
2024-01-19 10:54:14 +01:00
parent e1e6e6c1ab
commit 60a3e02420
4 changed files with 23 additions and 17 deletions

View File

@ -22,6 +22,7 @@ import TournamentCreateView from "./views/tournament/TournamentCreateView.js";
let client = new Client(location.protocol + "//" + location.host)
let lastView = undefined
let lastPageUrlBeforeLogin = undefined
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
@ -106,12 +107,14 @@ const router = async(uri) => {
if (lastView !== undefined)
await lastView.leavePage();
const view = new match.route.view(getParams(match));
const view = new match.route.view(getParams(match), lastPageUrlBeforeLogin);
if (view instanceof AbstractRedirectView && await view.redirect())
return 1;
lastView = view;
if (uri !== '/login' && uri !== '/register' && uri !== '/logout')
lastPageUrlBeforeLogin = uri;
if (await renderView(view))
return 1;