Refactor AuthController and update Login method
- Added using directive for EnvelopeGenerator.GeneratorAPI.Models. - Changed Login method parameter type from LogInDto to Login. - Modified HTTP route for Login method from "/form" to "form". - Enhanced XML documentation for better clarity on method usage. - Specified response type for successful login as text/javascript. - Removed ProducesResponseType for 500 Internal Server Error.
This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using DigitalData.UserManager.Application.DTOs.Auth;
|
using DigitalData.UserManager.Application.DTOs.Auth;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using EnvelopeGenerator.GeneratorAPI.Models;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
||||||
{
|
{
|
||||||
@@ -44,14 +45,11 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
/// <response code="200">Erfolgreiche Anmeldung. Gibt das JWT-Token im Antwortkörper oder als Cookie zurück, wenn 'cookie' wahr ist.</response>
|
/// <response code="200">Erfolgreiche Anmeldung. Gibt das JWT-Token im Antwortkörper oder als Cookie zurück, wenn 'cookie' wahr ist.</response>
|
||||||
/// <response code="401">Unbefugt. Ungültiger Benutzername oder Passwort.</response>
|
/// <response code="401">Unbefugt. Ungültiger Benutzername oder Passwort.</response>
|
||||||
/// <response code="500">Interner Serverfehler.</response>
|
|
||||||
[HttpPost]
|
|
||||||
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, "text/javascript")]
|
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, "text/javascript")]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Login([FromBody] LogInDto login, [FromQuery] bool cookie = false)
|
public async Task<IActionResult> Login([FromBody] Login login, [FromQuery] bool cookie = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -109,10 +107,21 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authentifiziert einen Benutzer und generiert ein JWT-Token. Das Token wird als HTTP-only-Cookie zurückgegeben.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="login">Benutzeranmeldedaten (Benutzername und Passwort).</param>
|
||||||
|
/// <returns>
|
||||||
|
/// Gibt eine HTTP 200 OK-Antwort als HTTP-Only-Cookie zurück.
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">Erfolgreiche Anmeldung. Gibt das JWT-Token im Antwortkörper oder als Cookie zurück, wenn 'cookie' wahr ist.</response>
|
||||||
|
/// <response code="401">Unbefugt. Ungültiger Benutzername oder Passwort.</response>
|
||||||
|
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, "text/javascript")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/form")]
|
[Route("form")]
|
||||||
public async Task<IActionResult> Login([FromForm] LogInDto login)
|
public async Task<IActionResult> Login([FromForm] Login login)
|
||||||
{
|
{
|
||||||
return await Login(login, true);
|
return await Login(login, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user