diff --git a/Marco.Pms.Model/Dtos/Authentication/LoginDto.cs b/Marco.Pms.Model/Dtos/Authentication/LoginDto.cs
index 536ac5d..ea7869c 100644
--- a/Marco.Pms.Model/Dtos/Authentication/LoginDto.cs
+++ b/Marco.Pms.Model/Dtos/Authentication/LoginDto.cs
@@ -2,9 +2,8 @@
{
public class LoginDto
{
- public string? Username { get; set; }
- public string? Password { get; set; }
- public string? DeviceToken { get; set; }
-
+ public required string Username { get; set; }
+ public required string Password { get; set; }
+ public required string DeviceToken { get; set; }
}
}
diff --git a/Marco.Pms.Services/Controllers/AuthController.cs b/Marco.Pms.Services/Controllers/AuthController.cs
index aa064ee..0bfa285 100644
--- a/Marco.Pms.Services/Controllers/AuthController.cs
+++ b/Marco.Pms.Services/Controllers/AuthController.cs
@@ -69,7 +69,7 @@ namespace MarcoBMS.Services.Controllers
}
catch (FirebaseMessagingException ex)
{
- _logger.LogError("Error sending push notification. : {Error}", ex.Message);
+ _logger.LogError(ex, "Error sending push notification.");
// Check for the specific error codes that indicate an invalid token
if (ex.MessagingErrorCode == MessagingErrorCode.Unregistered ||
@@ -145,13 +145,14 @@ namespace MarcoBMS.Services.Controllers
}
}
- [HttpPost("login-mobile")]
///
/// Handles mobile user login, validates credentials, sends a test push notification,
/// and generates JWT, Refresh, and MPIN tokens upon successful authentication.
///
/// Data Transfer Object containing the user's login credentials and device token.
/// An IActionResult containing the authentication tokens or an error response.
+
+ [HttpPost("login-mobile")]
public async Task LoginMobile([FromBody] LoginDto loginDto)
{
// Log the start of the login attempt for traceability.
@@ -179,7 +180,7 @@ namespace MarcoBMS.Services.Controllers
catch (FirebaseMessagingException ex)
{
// Log the specific Firebase error.
- _logger.LogError("Error sending push notification: {Error}", ex.Message);
+ _logger.LogError(ex, "Error sending push notification");
// Check for specific error codes that indicate an invalid or unregistered token.
if (ex.MessagingErrorCode == MessagingErrorCode.Unregistered ||
@@ -245,7 +246,7 @@ namespace MarcoBMS.Services.Controllers
if (string.IsNullOrWhiteSpace(user.UserName))
{
// This is an unlikely edge case, but good to handle.
- _logger.LogError("Login failed: User object for ID {UserId} is missing a UserName.", user.Id);
+ _logger.LogWarning("Login failed: User object for ID {UserId} is missing a UserName.", user.Id);
return NotFound(ApiResponse