CashMan H.A. provides a self-service password recovery mechanism that does not expose the existing password. Instead, when a user requests recovery, the system generates a one-time 5-digit numeric code and a 10-character hex token, delivers them to the user’s registered email address via PHPMailer, and then requires the user to prove possession of the email before allowing a password reset. The code is valid for 6 minutes, after which the session is expired and the user must restart the process.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/DanielRivera03/SistemaBancario/llms.txt
Use this file to discover all available pages before exploring further.
Recovery Flow
Visit the Forgot Password page
The user clicks the “Forgot Password” link on the login screen, which navigates to:This route renders the forgot-password form where the user enters their registered email address.
Submit email address
The form POSTs to
?cashmanha=recuperar-cuentas. The controller reads $_POST['val-email'] as the recovery destination.Code and token generation
The controller generates two values automatically:
- A 5-digit numeric code using
rand(10000, 99999) - A 10-character hex token using
bin2hex(random_bytes(5))
recuperacion database table before the email is sent.PHPMailer sends the recovery email
An HTML email is sent to the user’s address from The email also instructs the user that the code expires in 6 minutes and that the recovery process must be completed on the same device where it was initiated.
sistemas@cashmanha.com. The email body contains:- The 5-digit code rendered in a prominently styled block
- A “Change Password” button linking to:
Session state is initialized
After a successful email dispatch, the following session variables are written:
The
| Key | Value |
|---|---|
$_SESSION['TokenUsuarios'] | The generated hex token |
$_SESSION['CorreoUsuarios'] | The submitted email address |
$_SESSION['CodigoUsuarios'] | The generated 5-digit code |
$_SESSION['EstadoCodigos'] | "BloquearCodigoAcceso" |
BloquearCodigoAcceso state prevents a user from accessing the new-password form by navigating directly to the token URL without first entering the code.User enters the security code
The user opens Simultaneously,
?cashmanha=codigo-seguridad-recuperacion (or clicks the email button) and types their 5-digit code. On a correct match, the route ?cashmanha=cambio-estado-token is called, which upgrades the session state:CambioEstadoCodigoSeguridad() marks the token record in the database as "Usado", preventing replay.User submits a new password
With This renders the new-password form, which POSTs to
EstadoCodigos equal to "ValidarCodigoAcceso", the user can now access:?cashmanha=cambiar-contrasenia-recuperacion.New password is hashed and saved
The controller re-hashes the submitted password using the same SHA1 + The hash is then written to the database via
crypt() scheme used at registration:CambioContraseniaRecuperacion(), scoped to the email address stored in $_SESSION['CorreoUsuarios'].Confirmation email sent and session destroyed
A second HTML email is dispatched to the user confirming that their password has been successfully changed. Once the email is sent (or the attempt resolves), the controller calls
session_unset() and session_destroy(), fully clearing all recovery session state. The user is then directed to the success confirmation page.Recovery Route Reference
| Route | Method | Description |
|---|---|---|
?cashmanha=reestablecer-contrasena | GET | Render the forgot-password form |
?cashmanha=recuperar-cuentas | POST | Initiate recovery: generate code/token, send email, seed session |
?cashmanha=confirmacion-recuperacion-cuentas | GET | Confirmation page shown after email is sent |
?cashmanha=codigo-seguridad-recuperacion | GET | Code entry page (also the link target in the email) |
?cashmanha=cambio-estado-token | GET/POST | Validate the entered code and upgrade session state to ValidarCodigoAcceso |
?cashmanha=cambio-contrasenia-usuarios | GET | New password form (only accessible when state is ValidarCodigoAcceso) |
?cashmanha=cambiar-contrasenia-recuperacion | POST | Submit and apply the new hashed password via CambioContraseniaRecuperacion() |
?cashmanha=confirmacion-cambio-contrasenia | GET | Success page — destroys timer sessions and full session |
?cashmanha=error-cambio-contrasenia | GET | Error page — destroys timer sessions and full session |
?cashmanha=token-codigo-invalido | GET | Shown when the token in the URL is invalid or already expired |
Security Notes
- 6-minute code window — the email body explicitly states the code expires after 6 minutes. The
expiracion-cambio-contraseniaroute handles timed-out sessions by unsettingexpirar_sesionandtiempo_sesion, then destroying the full session. - Token state in the database — each token is stored in the
recuperaciontable with an initial state ofValido. When the code is validated,CambioEstadoCodigoSeguridad()marks itUsado, preventing the same code from being accepted a second time. - Direct URL access blocked — as long as
$_SESSION['EstadoCodigos']is"BloquearCodigoAcceso", the new-password form is inaccessible even if the attacker knows the token URL. Only a correct code entry flips the state to"ValidarCodigoAcceso".
The PHPMailer SMTP configuration in this codebase ships with an empty Refer to the PHPMailer documentation for additional settings required by production mail providers, such as
Host and Username, using port 2525 — the default for Papercut SMTP, a local test mail catcher. Email delivery will silently fail (and redirect to the login page) in any environment where Papercut is not running on port 2525. Before deploying to production, update the following fields in the recuperar-cuentas and cambiar-contrasenia-recuperacion cases with your real SMTP provider credentials:SMTPSecure.