How login works
The login form atLoggin.php accepts a cédula (7–8 digit Venezuelan national ID) and a password. On submission, the server:
- Validates that the cédula matches the pattern
^[0-9]{7,8}$. - Looks up the user in the
usuariostable with a prepared statement. - Checks the
activoflag — inactive accounts are rejected. - Verifies the password with PHP’s
password_verify()against the stored bcrypt hash. - On success, writes the user data to
$_SESSION['usuario']and redirects tohome.php.
auditoria table with the cédula, outcome, and IP address.
Default admin credentials
| Field | Value |
|---|---|
| Cédula | 12345678 |
| Password | Admin123! |
Session timeout
Each protected page includesheader.php, which enforces a 10-minute inactivity timeout:
header.php, the user is redirected to Loggin.php?error=Sesión+expirada+por+inactividad. The landing page home.php uses the slightly different parameter ?inactividad=1 on expiry and displays:
The timer resets on every full page load. AJAX calls to
actualizar_sesion.php can also extend the session without a full reload.Password recovery
The recovery flow inrecuperar_contraseña.php has four steps:
Enter your email address
Visit
recuperar_contraseña.php (linked from the login page as ¿Olvidó su contraseña?) and enter the email address registered to your account.Receive the verification code
The system generates a random 6-digit code, stores it in a temporary file on disk with a 3-minute expiry, and sends it to your email via PHPMailer over Gmail SMTP:The SMTP sender is configured as
[email protected]. To use a different address, update the Username, Password, and setFrom values in recuperar_contraseña.php.If SMTP delivery fails, the system falls back to displaying the recovery code directly on-screen with a warning message.
Enter the verification code
Type the 6-digit code sent to your email. You have 3 attempts before the code is invalidated. The countdown timer on the page shows the remaining validity window.
Set a new password
Enter and confirm your new password. It must satisfy all five criteria:
- At least 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one digit
- At least one special character
password_hash($nueva_clave, PASSWORD_DEFAULT) and stored in usuarios.password_hash.Changing your password from your profile
While logged in, go to Perfil (the user icon in the top-right navbar, orperfil.php). Click Cambiar Contraseña to reveal the inline form.
The same five-criteria validation applies:
Role-based access
Every user has one of two roles, stored inusuarios.rol:
Administrador
Full access to all modules: asset management, user management, system configuration, audit log, and database export.
Usuario
Can search assets, register and edit assets, and record movements. Cannot access Configuración or Gestión de Usuarios.
$_SESSION['usuario']['rol'] on every page. header.php sets the $es_administrador flag:
Security notes
Prepared statements
All database queries use
$conn->prepare() with bind_param(), preventing SQL injection throughout the codebase.bcrypt password hashing
Passwords are stored using PHP’s
password_hash() with PASSWORD_DEFAULT (bcrypt). Verification uses password_verify().Session management
Sessions expire after 10 minutes of inactivity.
session_destroy() is called on logout (salir.php) and on session expiry.Audit logging
Login attempts (success and failure), password changes, and data modifications are all recorded in the
auditoria table with a timestamp and IP address.