fix: add logout button to vendor onboarding page
The onboarding page was a standalone page with no way to log out, leaving users stuck. Added: - Logout button in the header - handleLogout() function to clear vendor tokens and redirect to login 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
29
static/vendor/js/onboarding.js
vendored
29
static/vendor/js/onboarding.js
vendored
@@ -603,6 +603,35 @@ function vendorOnboarding(initialLang = 'en') {
|
||||
}
|
||||
},
|
||||
|
||||
// Logout handler
|
||||
async handleLogout() {
|
||||
console.log('🚪 Logging out from onboarding...');
|
||||
|
||||
// Get vendor code from URL
|
||||
const path = window.location.pathname;
|
||||
const segments = path.split('/').filter(Boolean);
|
||||
const vendorCode = segments[0] === 'vendor' && segments[1] ? segments[1] : '';
|
||||
|
||||
try {
|
||||
// Call logout API
|
||||
await apiClient.post('/vendor/auth/logout');
|
||||
console.log('✅ Logout API called successfully');
|
||||
} catch (error) {
|
||||
console.error('⚠️ Logout API error (continuing anyway):', error);
|
||||
} finally {
|
||||
// Clear vendor tokens only (not admin or customer tokens)
|
||||
console.log('🧹 Clearing vendor tokens...');
|
||||
localStorage.removeItem('vendor_token');
|
||||
localStorage.removeItem('vendor_user');
|
||||
localStorage.removeItem('currentUser');
|
||||
localStorage.removeItem('vendorCode');
|
||||
// Note: Do NOT use localStorage.clear() - it would clear admin/customer tokens too
|
||||
|
||||
console.log('🔄 Redirecting to login...');
|
||||
window.location.href = `/vendor/${vendorCode}/login`;
|
||||
}
|
||||
},
|
||||
|
||||
// Dark mode
|
||||
get dark() {
|
||||
return localStorage.getItem('dark') === 'true' ||
|
||||
|
||||
Reference in New Issue
Block a user