Overview
The Auth Service handles user authentication and registration functionality for the CicloVital application. It provides methods for creating new user accounts and logging in existing users.API Configuration
The service uses environment-based API URL configuration:Functions
createUser
Creates a new user account in the system.User registration data containing user informationStructure:
- All required user fields for registration
- Validated by backend API
Response object with operation statusSuccess Response:Error Response:
POSTEndpoint:
{API_URL}
Example Usage
loginUser
Authenticates a user and establishes a session.User login credentialsStructure:
- Authentication credentials (username/email and password)
- Validated by backend API
Response object with authentication statusSuccess Response:Error Response:
POSTEndpoint:
{API_URL}/login
Example Usage
Error Handling
All service methods use a consistent error handling pattern:- Server Errors: Returns
error.response?.dataif available - Connection Errors: Returns default message:
'Error al conectar con el servidor.' - Response Format: Always returns
{ ok: boolean, data/messageError }
Source Code
Location:src/services/authService.js