- Request registration - Initiates the registration process for an employee
- Validate registration token - Verifies the registration token is valid
- Complete registration - Creates the account with username and password
RegistroCuentaController.java
POST /auth/register-request
Initiates the account registration process for an employee. If the employee code is valid and doesn’t have an existing account, sends a registration link to their email. Authentication: None required (public endpoint) Source:RegistroCuentaController.java:20
Request
The unique employee code (employee ID) assigned to the employee in the HR system.Note: For security reasons, the response is always successful regardless of whether the employee code is valid or already has an account.
Response
Always returns
true (or null in some cases)Confirmation message: “Si el colaborador es válido y no tiene cuenta, se enviará un correo.”
Example
Success Response
The response is intentionally vague to prevent enumeration of valid employee codes. An email is only sent if the employee code exists and doesn’t have an associated account.
POST /auth/validate-registration-token
Validates that a registration token is valid and not expired. Use this endpoint to verify a token before showing the account creation form. Authentication: None required (public endpoint) Source:RegistroCuentaController.java:30
Request
The registration token received via email. This token is typically extracted from the registration link URL.
Response
Success (200 OK):Returns
true if the token is valid and not expiredReturns
false if the token is invalid or expiredError message explaining why the token is invalid
Example
Success Response
Error Response
POST /auth/register-confirm
Completes the registration process by creating a new user account with the provided username and password. Authentication: None required (token-based verification) Source:RegistroCuentaController.java:41
Request
The valid registration token received via email
The desired username for the new account. Must be unique across the system.Requirements:
- Must be unique (not already in use)
- Typically 3-50 characters
- Alphanumeric characters recommended
The password for the new account. Should meet the application’s password complexity requirements.Requirements:
- Minimum length requirements
- Complexity requirements (uppercase, lowercase, numbers, special characters)
- Cannot be common or easily guessable
Response
Success (200 OK):Success message: “Cuenta creada exitosamente.”
Error message explaining why the registration failed (e.g., invalid token, username already taken, weak password)
Generic error message: “Error interno al crear la cuenta.”
Example
Success Response
Error Responses
Invalid or expired token:Complete Registration Flow
Here’s how the three endpoints work together:Employee requests registration
New employee enters their employee code on the registration request page. Your application calls
POST /auth/register-request.Employee receives email
If the employee code is valid and has no existing account, the employee receives an email with a registration link containing a token:
Validate the token
When the employee clicks the link, your application extracts the token from the URL and calls
POST /auth/validate-registration-token to verify it’s valid before showing the registration form.Employee creates account
Employee fills out the registration form with their desired username and password. Your application calls
POST /auth/register-confirm.The employee code must correspond to an existing employee record in the HR system. Employees cannot register without a valid employee code, ensuring only authorized personnel can create accounts.