Skip to content

Commit 4bf1296

Browse files
Launch settings set to tru to run swagger. Hash the input password first to match it with the db password field
1 parent 2f1eab6 commit 4bf1296

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

UserManagementApi/Controllers/UsersController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task<ActionResult<AuthResponse>> Authenticate([FromBody] DTO.LoginR
3838
var user = await _db.Users
3939
.Include(u => u.UserRoles)
4040
.ThenInclude(ur => ur.Role)
41-
.FirstOrDefaultAsync(u => u.UserName == req.UserName && u.Password == req.Password);
41+
.FirstOrDefaultAsync(u => u.UserName == req.UserName && u.Password == BCrypt.Net.BCrypt.HashPassword(req.Password));
4242

4343
if (user == null)
4444
return Unauthorized("Invalid credentials.");

UserManagementApi/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
if (app.Environment.IsDevelopment())
9292
{
9393
app.MapOpenApi();
94+
app.UseSwagger();
95+
app.UseSwaggerUI(c =>
96+
{
97+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "User Management API v1");
98+
c.RoutePrefix = string.Empty; // Swagger UI at root "/"
99+
});
94100
}
95101

96102
app.UseHttpsRedirection();

UserManagementApi/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"http": {
55
"commandName": "Project",
66
"dotnetRunMessages": true,
7-
"launchBrowser": false,
7+
"launchBrowser": true,
88
"applicationUrl": "http://localhost:5004",
99
"environmentVariables": {
1010
"ASPNETCORE_ENVIRONMENT": "Development"
@@ -13,7 +13,7 @@
1313
"https": {
1414
"commandName": "Project",
1515
"dotnetRunMessages": true,
16-
"launchBrowser": false,
16+
"launchBrowser": true,
1717
"applicationUrl": "https://localhost:7093;http://localhost:5004",
1818
"environmentVariables": {
1919
"ASPNETCORE_ENVIRONMENT": "Development"

0 commit comments

Comments
 (0)