Home
About Us
About Us
Courses
Events
Our Global Ambassadors
Photo/Video Gallery
Press/Media
Blog
Contact
Photos and Events Gallery
Home
Pages
Photos and Events Gallery
Seminars & Workshops
Educational and career development events
Personality Enhancement and Career Guidance Program
Maratha Mandal College
Seminar at KLE
Vastu Parikshana
Third Eye
Third Eye Activation Event for Kids
Third Eye Actiation Program For Kids
MY Gangoor Academy
Feedback of our Sadhakas
Yoga For Beginners
Hatha Yoga
Yoga For Beginners
Hatha Yoga
Yoga For Beginners
Hatha Yoga
Video Player
×
// Check authentication status and show/hide dashboard icon async function checkAuthAndShowDashboard() { try { const apiBase = window.API_BASE_URL || '/api'; const response = await fetch(`${apiBase}/auth/check`, { method: 'GET', credentials: 'include', headers: { 'Content-Type': 'application/json', } }); const data = await response.json(); const dashboardNavItem = document.getElementById('dashboardNavItem'); if (data.ok && data.user) { // User is authenticated - show dashboard icon if (dashboardNavItem) { dashboardNavItem.style.display = 'list-item'; } } else { // User is not authenticated - hide dashboard icon if (dashboardNavItem) { dashboardNavItem.style.display = 'none'; } } } catch (error) { console.error('Error checking authentication for dashboard icon:', error); // On error, hide the icon to be safe const dashboardNavItem = document.getElementById('dashboardNavItem'); if (dashboardNavItem) { dashboardNavItem.style.display = 'none'; } } } // Handle dashboard icon click - navigate to appropriate dashboard based on role async function handleDashboardClick(event) { event.preventDefault(); try { const response = await fetch('/api/auth/check', { method: 'GET', credentials: 'include', headers: { 'Content-Type': 'application/json', } }); const data = await response.json(); if (data.ok && data.user) { const role = data.user.role; const userRole = String(role || '').toLowerCase(); // Navigate based on role (same logic as NavBar.tsx) if (userRole.startsWith('org')) { // Org roles go to dashboard window.location.href = '/dashboard'; } else { switch (userRole) { case 'superadmin': window.location.href = '/superadmin'; break; case 'admin': window.location.href = '/admin'; break; case 'vendor': window.location.href = '/vendor'; break; case 'student': window.location.href = '/dashboard'; break; default: window.location.href = '/dashboard'; } } } else { // User is not authenticated, redirect to login window.location.href = '/login?returnUrl=/home'; } } catch (error) { console.error('Error navigating to dashboard:', error); // On error, redirect to login window.location.href = '/login?returnUrl=/home'; } } // Call checkAuthAndShowDashboard when page loads window.addEventListener('DOMContentLoaded', checkAuthAndShowDashboard);