You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
using BukiVedi.App.Requests;
|
|
using BukiVedi.App.Responces;
|
|
using BukiVedi.Shared.Models;
|
|
using BukiVedi.Shared.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BukiVedi.App.Controllers
|
|
{
|
|
[ApiController]
|
|
public class AuthController
|
|
: BaseController
|
|
{
|
|
public AuthController()
|
|
: base()
|
|
{
|
|
|
|
}
|
|
|
|
[HttpPost("/api/auth")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
public async Task<ActionResult<AutoCodeResponse>> SignIn([FromBody] AuthLPRequest request)
|
|
{
|
|
var acc = await OperationContext.AuthProvider.GetAccount(request?.Login!, request?.Password!);
|
|
if (acc == null)
|
|
{
|
|
return Ok(new AutoCodeResponse { Success = false, ReasonPhrase = "Аккаунт не найден" });
|
|
}
|
|
var token = UserTokenGenerator.GenerateUserToken(acc);
|
|
return Ok(new AutoCodeResponse
|
|
{
|
|
Success = true,
|
|
Token = token
|
|
});
|
|
}
|
|
}
|
|
}
|