Overview
The authentication system provides secure access control with role-based permissions for dental clinic staff. The application supports two user roles: dentists and receptionists, each with specific access levels.User Roles
The system currently supports two predefined user roles:Dentista
Full access to patient records, treatments, and appointments
Recepcionista
Access to appointment scheduling and patient basic information
Authentication Flow
Login Component
The login functionality is implemented insrc/app/login/login.ts. Here’s the core implementation:
Component Structure
Form Validation
The login form uses Angular’s reactive forms with built-in validators:The email field includes both required and email format validation, ensuring proper input before authentication attempts.
Login Handler
The authentication logic is handled by thehandleLogin() method:
Session Management
User sessions are managed through browser localStorage:- Storage: User role is stored upon successful login
- Key:
userRole - Values:
'dentista'or'recepcionista'
Accessing Current User Role
Test Credentials
For development and testing purposes, the following credentials are available:| Role | Password | |
|---|---|---|
| Dentista | [email protected] | 123 |
| Recepcionista | [email protected] | 123 |
Error Handling
The authentication system provides clear error messages:- Invalid form data: “Datos incompletos o correo no válido.”
- Invalid credentials: “Correo o contraseña incorrectos.”
- Navigation errors: Logged to console for debugging
Routing Configuration
Authentication routes are defined insrc/app/app.routes.ts:
Security Considerations
Current Implementation: The current authentication is client-side only and suitable for prototyping.Production Requirements:
- Implement server-side authentication
- Use secure password hashing (bcrypt, Argon2)
- Implement JWT or session-based authentication
- Add HTTPS enforcement
- Implement proper CSRF protection
- Add rate limiting for login attempts
Next Steps
To enhance the authentication system:- Integrate with a backend authentication service
- Implement token-based authentication (JWT)
- Add password reset functionality
- Implement multi-factor authentication (MFA)
- Add session timeout and auto-logout
- Create route guards based on user roles
Related Components
- Patient Management - Access controlled by user role
- Appointment Scheduling - Available to all authenticated users