Overview
The Sistema de Permisos Municipales uses session-based authentication with bcrypt password hashing to secure user access. All users must log in with their credentials before accessing the system.Login process
Users authenticate with a username (indicador) and password. The system validates credentials and creates a session.Login endpoint
User’s username (generated from name and surname, e.g., MALAVEN)
User’s password (minimum 6 characters, maximum 30 characters)
Validation rules
The system enforces the following validation rules during login:Username validation
Username validation
- Must be at least 3 characters long
- Must not exceed 51 characters
- Cannot contain numbers
- Automatically converted to uppercase
Password validation
Password validation
- Must be at least 6 characters
- Must not exceed 30 characters
- Stored as bcrypt hash with 10 salt rounds
Successful login
On successful authentication, the system creates a session with the following user information:The session persists across requests until the user logs out or the session expires.
Password management
Changing your password
Users can change their password through the password change interface:Submit the form
The system validates your current password and ensures the new password meets requirements.
Password change endpoint
Session management
Session configuration
Sessions are configured with the following settings:Logging out
To end a session, users can log out:Protected routes
All routes in the system require authentication. The system checks forreq.session.usuario before allowing access:
Some routes also require specific user roles (Administrador, Desarrollador) for access.
Security features
Password hashing
All passwords are hashed using bcrypt with 10 salt rounds before storage.
Session security
Sessions use a secret key and don’t save uninitialized sessions.
Validation
Strict validation rules prevent weak passwords and invalid usernames.
Automatic logout
Password changes automatically log out the user for security.
Error handling
The system provides specific error messages for common authentication issues:| Error | Meaning |
|---|---|
| ¡Debe introducir su indicador de usuario! | Username field is empty |
| ¡El indicador debe contener, por lo menos, 3 letras! | Username too short |
| ¡Usuario no encontrado! | Username doesn’t exist |
| ¡Contraseña incorrecta! | Password doesn’t match |
| ¡La contraseña debe contener, por lo menos, 6 caracteres! | Password too short |
Next steps
User management
Learn how to create and manage user accounts
Roles and permissions
Understand user roles and access control