Overview
SGD-MCS uses a protected route system to manage authentication and user access. The system is designed to integrate with Google Apps Script authentication while providing flexibility for future authentication methods.Authentication Architecture
The authentication system consists of two main components:- ProtectedRoute Component - Guards private routes
- Google Apps Script Integration - Backend authentication via GAS
ProtectedRoute Component
Location:Fronted/src/components/common/ProtectedRoute.jsx:9
The ProtectedRoute component wraps all private application routes and redirects unauthenticated users to the login page.
The current implementation uses a hardcoded
true value for development purposes. In production, this should be replaced with actual authentication logic.Setting Up Authentication
Configure Route Protection
All protected routes are wrapped in the
ProtectedRoute component in App.jsx:80:Add Authentication Context
Create an AuthContext to manage authentication state across the application:
User Session Management
Storing User Information
User information is typically stored in the application state or localStorage:Logout Functionality
Google Apps Script Authentication
When deployed as a Google Apps Script web app, authentication is handled automatically by Google:Set Deployment Permissions
In Google Apps Script:
- Click Deploy > New deployment
- Choose Web app
- Set “Execute as” to Me
- Set “Who has access” to Anyone with Google account or specific domain
Development vs Production
Development Mode
In development (localhost), authentication is bypassed:Production Mode
In production (Google Apps Script), use real authentication:Best Practices
The current implementation at
Fronted/src/components/common/ProtectedRoute.jsx:12 allows full access during development. Remember to implement proper authentication before deploying to production.Next Steps
- Learn about Managing Entities to work with student and teacher records
- Explore Document Upload to handle file management
- Review Drive Integration for Google Drive synchronization