front: redirect to last visited page after login
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user