Description
Creates a new user account in the system. Passwords are automatically hashed using ASP.NET Core Identity’s PasswordHasher before storage.
Authentication
No authentication required (public endpoint).
Request Body
Username for the new account. Maximum length: 100 characters. Must be unique.
User’s password. Will be securely hashed before storage.
Role assigned to the user (e.g., “Admin”, “User”, “Manager”).
Response
Success Response (200 OK)
Success message: “Usuario creado con éxito”
Error Response (400 Bad Request)
Error message: “Error al crear el usuario”
Examples
Successful Registration
curl -X POST https://api.example.com/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"NombreUsuario": "johndoe",
"password": "SecurePassword123",
"Rol": "User"
}'
Failed Registration
curl -X POST https://api.example.com/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"NombreUsuario": "",
"password": "password123",
"Rol": "User"
}'
Security Notes
- Passwords are hashed using
PasswordHasher<Usuario> from ASP.NET Core Identity
- Original passwords are never stored in plain text
- Password verification uses secure comparison algorithms
Validation Rules
- NombreUsuario: Required, maximum 100 characters
- password: Required
- Rol: Required