This commit is contained in:
parent
95b0e099ae
commit
fca54b30dd
3
main.ts
3
main.ts
@ -149,7 +149,8 @@ function authMiddleware(): oak.Middleware {
|
||||
return async (ctx, next) => {
|
||||
const token = await ctx.cookies.get("Authorization");
|
||||
if (!token || !await db.sessionWhereToken(token)) {
|
||||
ctx.response.redirect("/login.html");
|
||||
const path = encodeURIComponent(ctx.request.url.pathname);
|
||||
ctx.response.redirect(`/login.html?refer=${path}`);
|
||||
return;
|
||||
}
|
||||
await next();
|
||||
|
@ -18,6 +18,11 @@ document.querySelector("#login").onsubmit = async (event) => {
|
||||
loginErrorSpan.hidden = false;
|
||||
return;
|
||||
}
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (!params.has("refer")) {
|
||||
window.location.pathname = "/";
|
||||
return;
|
||||
}
|
||||
window.location.pathname = decodeURIComponent(params.get("refer"));
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user