Add: redirect local storage var after login
This commit is contained in:
parent
c4b4b238de
commit
8f7c20cb4b
1 changed files with 4 additions and 0 deletions
|
@ -92,6 +92,10 @@ export const login = async (username: string, password: string) => {
|
||||||
|
|
||||||
// Logout function
|
// Logout function
|
||||||
export const logout = () => {
|
export const logout = () => {
|
||||||
|
// Store the current path before redirecting to login
|
||||||
|
localStorage.setItem("redirect_after_login", window.location.pathname);
|
||||||
|
|
||||||
|
// Clear tokens and redirect to login page
|
||||||
localStorage.removeItem("access_token");
|
localStorage.removeItem("access_token");
|
||||||
localStorage.removeItem("refresh_token");
|
localStorage.removeItem("refresh_token");
|
||||||
window.location.href = "/user/login"; // Redirect to login page
|
window.location.href = "/user/login"; // Redirect to login page
|
||||||
|
|
Loading…
Add table
Reference in a new issue