diff --git a/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/GenerateJwtTokenCommandHandler.cs b/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/GenerateJwtTokenCommandHandler.cs index 9536d8a..89cff3d 100644 --- a/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/GenerateJwtTokenCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/GenerateJwtTokenCommandHandler.cs @@ -34,7 +34,9 @@ public async Task Handle(GenerateJwtTokenCommand request, CancellationTo { new Claim(ClaimTypes.Sid, request.User.UserId.ToString()), new Claim(ClaimTypes.Email, request.User.Email), - new Claim(ClaimTypes.Name, request.User.FirstName + " " + request.User.LastName) + new Claim(ClaimTypes.Name, request.User.FirstName + " " + request.User.LastName), + new Claim(ClaimTypes.Role, request.User.Artist != null ? "Artist" : (request.User.Hobbyist != null ? "Hobbyist" : "")), + new Claim(ClaimTypes.NameIdentifier, request.User.Artist != null ? request.User.Artist.ArtistId.ToString() : (request.User.Hobbyist != null ? request.User.Hobbyist.HobbyistId.ToString() : "")) }), Expires = DateTime.UtcNow.AddHours(4), SigningCredentials = new SigningCredentials( @@ -42,6 +44,8 @@ public async Task Handle(GenerateJwtTokenCommand request, CancellationTo SecurityAlgorithms.HmacSha512Signature) }; var tokenHandler = new JwtSecurityTokenHandler(); + tokenHandler.InboundClaimTypeMap.Clear(); + tokenHandler.InboundClaimTypeMap.Add("nameid", "usertypeid"); var token = tokenHandler.CreateToken(tokenDescriptor); var tokenStr = tokenHandler.WriteToken(token); diff --git a/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/LogInUserCommandHandler.cs b/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/LogInUserCommandHandler.cs index fc1518b..5e5d665 100644 --- a/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/LogInUserCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Application/Commands/Handlers/LogInUserCommandHandler.cs @@ -48,7 +48,6 @@ public async Task Handle(LogInUserCommand request, Cancell { Token = null, Message = "Username or password is incorrect.", - UserType = null }; } var generateTokenCommand = new GenerateJwtTokenCommand { User = user }; @@ -56,8 +55,7 @@ public async Task Handle(LogInUserCommand request, Cancell var response = new AuthenticateResponse { Token = jwtToken, - Message = "User logged in successfully", - UserType = user.Artist != null ? "Artist" : (user.Hobbyist != null ? "Hobbyist" : null) + Message = "User logged in successfully" }; UserLoggedInEvent userLoggedInEvent = new UserLoggedInEvent(); await _publisher.Publish(userLoggedInEvent); diff --git a/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Interfaces/REST/Resources/AuthenticateResponse.cs b/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Interfaces/REST/Resources/AuthenticateResponse.cs index aeb24f3..f09ebe3 100644 --- a/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Interfaces/REST/Resources/AuthenticateResponse.cs +++ b/PERUSTARS/PERUSTARS/IdentityAndAccountManagement/Interfaces/REST/Resources/AuthenticateResponse.cs @@ -4,7 +4,6 @@ public class AuthenticateResponse { public string? Token { get; set; } public string Message { get; set; } - public string? UserType { get; set; } } } diff --git a/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.dll b/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.dll index c4c3c6d..70bc558 100644 Binary files a/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.dll and b/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.dll differ diff --git a/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.pdb b/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.pdb index 57df567..be5d220 100644 Binary files a/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.pdb and b/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.pdb differ diff --git a/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.runtimeconfig.dev.json b/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.runtimeconfig.dev.json index 95de746..84855df 100644 --- a/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.runtimeconfig.dev.json +++ b/PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.runtimeconfig.dev.json @@ -1,9 +1,8 @@ { "runtimeOptions": { "additionalProbingPaths": [ - "C:\\Users\\HP\\.dotnet\\store\\|arch|\\|tfm|", - "C:\\Users\\HP\\.nuget\\packages", - "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages" + "C:\\Users\\Mauricio\\.dotnet\\store\\|arch|\\|tfm|", + "C:\\Users\\Mauricio\\.nuget\\packages" ] } } \ No newline at end of file