From 2e6d54a7cc2ff9fb6a75ff7b2936fe9b8ca67397 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Mon, 13 Oct 2025 15:00:16 +0200 Subject: [PATCH] updating DTO --- .../DTO/Login/Request/ConnectLoginDto.cs | 7 ++++ .../DTO/Login/Request/CreateLoginDto.cs | 1 - .../DTO/Login/Request/UpdateLoginDto.cs | 1 - .../Endpoints/Login/CreateLoginEndpoint.cs | 7 ++-- .../Endpoints/Login/UpdateLoginEndpoint.cs | 6 ++- .../Endpoints/Login/UserLoginEndpoint.cs | 37 +++++++++++++++++++ 6 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 ApiEfCoreLibrary/DTO/Login/Request/ConnectLoginDto.cs create mode 100644 ApiEfCoreLibrary/Endpoints/Login/UserLoginEndpoint.cs diff --git a/ApiEfCoreLibrary/DTO/Login/Request/ConnectLoginDto.cs b/ApiEfCoreLibrary/DTO/Login/Request/ConnectLoginDto.cs new file mode 100644 index 0000000..3919169 --- /dev/null +++ b/ApiEfCoreLibrary/DTO/Login/Request/ConnectLoginDto.cs @@ -0,0 +1,7 @@ +namespace ApiEfCoreLibrary.DTO.Login.Request; + +public class ConnectLoginDto +{ + public string? Username { get; set; } + public string? Password { get; set; } +} \ No newline at end of file diff --git a/ApiEfCoreLibrary/DTO/Login/Request/CreateLoginDto.cs b/ApiEfCoreLibrary/DTO/Login/Request/CreateLoginDto.cs index 597e97d..8cc94dc 100644 --- a/ApiEfCoreLibrary/DTO/Login/Request/CreateLoginDto.cs +++ b/ApiEfCoreLibrary/DTO/Login/Request/CreateLoginDto.cs @@ -5,5 +5,4 @@ public class CreateLoginDto public string? Username { get; set; } public string? FullName { get; set; } public string? Password { get; set; } - public string? Salt { get; set; } } \ No newline at end of file diff --git a/ApiEfCoreLibrary/DTO/Login/Request/UpdateLoginDto.cs b/ApiEfCoreLibrary/DTO/Login/Request/UpdateLoginDto.cs index 5bcaf6a..1b717d4 100644 --- a/ApiEfCoreLibrary/DTO/Login/Request/UpdateLoginDto.cs +++ b/ApiEfCoreLibrary/DTO/Login/Request/UpdateLoginDto.cs @@ -6,5 +6,4 @@ public class UpdateLoginDto public string? Username { get; set; } public string? FullName { get; set; } public string? Password { get; set; } - public string? Salt { get; set; } } \ No newline at end of file diff --git a/ApiEfCoreLibrary/Endpoints/Login/CreateLoginEndpoint.cs b/ApiEfCoreLibrary/Endpoints/Login/CreateLoginEndpoint.cs index 2a83ce6..e9cec77 100644 --- a/ApiEfCoreLibrary/Endpoints/Login/CreateLoginEndpoint.cs +++ b/ApiEfCoreLibrary/Endpoints/Login/CreateLoginEndpoint.cs @@ -1,6 +1,5 @@ using ApiEfCoreLibrary.DTO.Login.Request; using ApiEfCoreLibrary.DTO.Login.Response; -using BCrypt.Net; namespace ApiEfCoreLibrary.Endpoints.Login; using FastEndpoints; @@ -15,12 +14,14 @@ public class CreateLoginEndpoint(LibraryDbContext database) : Endpoint + { + o.SigningKey = "A secret token signing key"; + o.ExpireAt = DateTime.UtcNow.AddDays(1); + o.User.Roles.Add("Manager", "Auditor"); + o.User.Claims.Add(("UserName", req.Username)); + o.User["UserId"] = "001"; //indexer based claim setting + }); + + await Send.OkAsync( + new + { + req.Username, + Token = jwtToken + }); + } + else + ThrowError("The supplied credentials are invalid!"); + } +} \ No newline at end of file