Verbesserung der Login-Methode und Vereinfachung der IsAuthenticated-Route
- Die Login-Methode wurde geändert, um einen zusätzlichen `bool cookie`-Parameter für mehr Flexibilität zu akzeptieren. - Hinzufügen einer neuen Login-Methode, die LogInDto aus Formulardaten verarbeitet und die ursprüngliche Methode mit `cookie` auf true setzt. - Aufnahme eines Platzhalters für JWT- und Cookie-Handling in die ursprüngliche Login-Methode.
This commit is contained in:
@@ -27,11 +27,15 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
|
|
||||||
//TODO: When a user group is created for signFlow, add a process to check if the user is in this group (like "PM_USER")
|
//TODO: When a user group is created for signFlow, add a process to check if the user is in this group (like "PM_USER")
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost("login")]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Login([FromBody] LogInDto login)
|
public async Task<IActionResult> Login([FromBody] LogInDto login, bool cookie = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
return Ok();
|
||||||
|
|
||||||
|
throw new NotImplementedException("JWT and cookie option is not implemented");
|
||||||
|
|
||||||
bool isValid = _dirSearchService.ValidateCredentials(login.Username, login.Password);
|
bool isValid = _dirSearchService.ValidateCredentials(login.Username, login.Password);
|
||||||
|
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
@@ -82,6 +86,14 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpPost]
|
||||||
|
[Route("/login")]
|
||||||
|
public async Task<IActionResult> Login([FromForm] LogInDto login)
|
||||||
|
{
|
||||||
|
return await Login(login, true);
|
||||||
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpPost("logout")]
|
[HttpPost("logout")]
|
||||||
public async Task<IActionResult> Logout()
|
public async Task<IActionResult> Logout()
|
||||||
@@ -99,7 +111,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpGet("check")]
|
[HttpGet]
|
||||||
public IActionResult IsAuthenticated() => Ok(User.Identity?.IsAuthenticated ?? false);
|
public IActionResult IsAuthenticated() => Ok(User.Identity?.IsAuthenticated ?? false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user