Redirect back to previous page after login

This commit is contained in:
Yukino Song
2024-09-19 04:39:44 +08:00
parent 8e8f89d514
commit ba22fa9a3e
2 changed files with 16 additions and 2 deletions

View File

@@ -91,7 +91,14 @@
if (res.status === 200) {
this.success = true;
localStorage.setItem('login', JSON.stringify(this.passwordData));
location.href = './';
const url = new URL(window.location);
const redirectUrl = url.searchParams.get('redir');
const hash = url.hash;
if (redirectUrl) {
location.href = redirectUrl + hash;
} else {
location.href = './' + hash;
}
} else {
if (res.status === 401) {
throw new Error('Please check your username and password')