feat: remember last visited page after login
Users are now redirected to their last visited page after logging in, instead of always going to the dashboard. Implementation: - Track current page in localStorage on every page load - Exclude login, logout, onboarding, and error pages from tracking - On login success, redirect to last visited page if valid - Clear last visited page on logout Admin: - static/admin/js/init-alpine.js: Save page to admin_last_visited_page - static/admin/js/login.js: Redirect to last page after login - app/templates/admin/partials/header.html: Clear on logout Vendor: - static/vendor/js/init-alpine.js: Save page to vendor_last_visited_page - static/vendor/js/login.js: Redirect to last page (validates vendor code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,24 @@ function data() {
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────
|
||||
// Last visited page tracking (for redirect after login)
|
||||
// ─────────────────────────────────────────────────────────────────
|
||||
const LAST_PAGE_KEY = 'admin_last_visited_page';
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
// Save current page (exclude login, logout, error pages)
|
||||
if (currentPath.startsWith('/admin/') &&
|
||||
!currentPath.includes('/login') &&
|
||||
!currentPath.includes('/logout') &&
|
||||
!currentPath.includes('/errors/')) {
|
||||
try {
|
||||
window.localStorage.setItem(LAST_PAGE_KEY, currentPath);
|
||||
} catch (e) {
|
||||
// Ignore storage errors
|
||||
}
|
||||
}
|
||||
|
||||
// Map pages to their parent sections
|
||||
const pageSectionMap = {
|
||||
// Platform Administration
|
||||
|
||||
Reference in New Issue
Block a user