Overview
The Certificate API generates official certificates (constancias) that verify an employee has completed the background evaluation process. Certificates include QR codes for third-party validation.Certificates are generated with encrypted QR codes that allow external organizations to verify authenticity through the Validation API.
View Certificate
Endpoint
Authentication
Requires active user session (authenticated via session middleware).Path Parameters
Encrypted validation string that contains the evaluation ID. This same string is used in the QR code for certificate validation.
Response
Returns an HTML view (constanciaViews/constanciaView) displaying the certificate with:
Current user’s name from session.
Base64-encoded QR code image (Data URL format).
Certificate metadata and validation information.
Employee information displayed on certificate.
QR Code Generation
The QR code is generated using theqrcode library and contains a validation URL:
- Format: PNG image as Data URL
- Content: Full validation URL with encrypted evaluation ID
- Purpose: Allow third parties to verify certificate authenticity
- Validation Endpoint:
/Validator/ConstanciaValidator/:cadena
Database Queries
Get Certificate Data:Decryption Process
TheconstanciaValidacion parameter is decrypted to retrieve the evaluation ID:
Error Handling
Silent error handling - errors are caught but not displayed to user. The view may render empty or redirect based on error type.Certificate Data Structure
Certificate Record
Stored intbl_dgo_constancias table:
Auto-increment primary key.
Foreign key to evaluation record.
Encrypted validation string (ncrypt-js).
Timestamp of certificate creation.
Soft delete flag (1 = active, 0 = deleted).
Certificate Validation Workflow
Generation Process
- Evaluation Complete: Employee completes background evaluation
- Generate Certificate: System creates certificate record with validation string
- Encrypt ID: Evaluation ID encrypted using ncrypt-js
- Create QR Code: QR code generated with validation URL
- Display Certificate: HTML view rendered with employee data and QR code
Validation Process
- QR Scan: External party scans QR code on certificate
- URL Redirect: QR code redirects to validation endpoint
- Decrypt ID: Server decrypts validation string
- Query Database: Retrieves certificate and employee data
- Display Validation: Shows certificate details and authenticity confirmation
Certificate Display Format
Visual Elements
- Header: Official CEACC Durango logo and letterhead
- Title: “Constancia de Evaluación” or similar
- Employee Name: Full name prominently displayed
- RFC: Tax identifier for verification
- Issuance Date: Date certificate was generated
- QR Code: Positioned for easy scanning (typically bottom-right)
- Validation Text: Instructions for QR code verification
- Official Signature: Digital or scanned signature of authority
- Folio Number: Certificate identifier for reference
Print Optimization
The certificate view is designed for printing:- Standard letter size (8.5” × 11”)
- Print-friendly styling
- High-resolution QR code
- Official color scheme
QR Code Technical Details
Library
Package:qrcode (npm)
Version: Check package.json in source code
Documentation: https://www.npmjs.com/package/qrcode
Generation Method
QR Code Content
The QR code encodes a full URL:- Protocol: http:// or https://
- Domain: System domain (appears to be placeholder in code)
- Path:
/constanciaValidator/ - Parameter: Encrypted evaluation ID
Security Features
- Encryption: Validation string encrypted with ncrypt-js
- Active Check: Only active certificates (constanciaActivo = 1) validate
- Database Verification: QR code links to live database record
- Tamper-Proof: Any modification to encrypted string breaks validation
Source Code References
Routes
ConstanciaRoutes.js:6
Controller
ConstanciaController.js:6-29
Key operations:
- Decrypt validation parameter
- Query certificate data
- Query employee data
- Generate QR code
- Render view
Models
ConstanciaModel.js:2-8
SQL queries for retrieving certificate and employee information.
Integration Example
Creating a Certificate
While the API doesn’t expose a POST endpoint for certificate creation in the provided code, certificates are likely created during the evaluation completion process:Displaying Certificate
Use Cases
- Official Certification: Provide employees with proof of completed background check
- Third-Party Verification: Allow employers to verify certificate authenticity
- Compliance Documentation: Meet regulatory requirements for background checks
- Digital Records: Maintain digital certificates alongside paper copies
- Anti-Fraud: Prevent forged or altered certificates through QR validation
Best Practices
Security
- Always use HTTPS in production for validation URLs
- Rotate encryption keys periodically
- Log validation attempts for audit trail
- Implement rate limiting on validation endpoint
User Experience
- Provide clear instructions for QR code scanning
- Include manual validation option (folio number lookup)
- Ensure QR code is high-contrast and scannable
- Test QR codes with multiple scanner apps
Reliability
- Cache certificate views to reduce database load
- Handle expired certificates gracefully
- Implement proper error logging
- Provide fallback validation methods