mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-17 01:00:07 +01:00
fix: revert passing password hash for jwt generation
builder in Program.cs is not aware of it, so [Authorize] decorator can't be provided data necessary to validate requests which contain JWT with password
This commit is contained in:
@@ -15,16 +15,18 @@ public class AuthController : ControllerBase
|
||||
|
||||
private readonly IConfiguration _appsettings;
|
||||
private readonly ApplicationDbContext _db;
|
||||
private readonly GeneralUseHelpers guhf;
|
||||
|
||||
public AuthController(IConfiguration appsettings, ApplicationDbContext db)
|
||||
public AuthController(IConfiguration appsettings, ApplicationDbContext db, GeneralUseHelpers GUHF)
|
||||
{
|
||||
_db = db;
|
||||
_appsettings = appsettings;
|
||||
guhf = GUHF;
|
||||
}
|
||||
|
||||
// POST /api/v1/auth/login
|
||||
[HttpPost("login")]
|
||||
public async Task<IActionResult> Login([FromBody] UserLoginDTO formUser, GeneralUseHelpers guhf)
|
||||
public async Task<IActionResult> Login([FromBody] UserLoginDTO formUser)
|
||||
{
|
||||
// Ensure the form is complete
|
||||
if (formUser.Email == null || formUser.Password == null)
|
||||
@@ -44,7 +46,7 @@ public class AuthController : ControllerBase
|
||||
if (hashedFormPassword == user.PasswordHash)
|
||||
{
|
||||
// All set - generate the token and return it
|
||||
var token = guhf.GenerateJwtToken(formUser.Email, formUser.Password);
|
||||
var token = guhf.GenerateJwtToken(formUser.Email);
|
||||
return Ok(new { status = "ok", token });
|
||||
} else return Unauthorized(new {status = "error", error_msg = "Unknown pair of email and password"});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user