...
This commit is contained in:
53
Presentation/Hushian.WebApi/Controllers/v1/AuthController.cs
Normal file
53
Presentation/Hushian.WebApi/Controllers/v1/AuthController.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Common.Models.Auth;
|
||||
using Common.Models.Auth.CompanySide;
|
||||
using Common.Models.Auth.UserSide;
|
||||
using Hushian.Application.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Hushian.WebApi.Controllers.v1
|
||||
{
|
||||
[Route("api/v1/[controller]")]
|
||||
[ApiController]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
private readonly AuthService _authService;
|
||||
private readonly VerificationService _verificationService;
|
||||
public AuthController(AuthService authService, VerificationService verificationService)
|
||||
{
|
||||
_authService = authService;
|
||||
_verificationService = verificationService;
|
||||
}
|
||||
|
||||
[HttpPost("loginCompanySide")]
|
||||
public async Task<ActionResult<AuthResponse>> login([FromBody] AuthRequestFromCompanySide request)
|
||||
{
|
||||
var response = await _authService.AuthenticationFromCompanySide(request);
|
||||
if (response.Success) return Ok(response.Value);
|
||||
else return BadRequest(response.Errors);
|
||||
}
|
||||
[HttpPost("AuthenticationFromUser")]
|
||||
public async Task<ActionResult<int>> AuthenticationFromUser([FromBody] AuthRequestFromUserSide request)
|
||||
{
|
||||
var response = await _authService.AuthenticationFromUserSide(request);
|
||||
if (response.Success) return Ok(response.Value);
|
||||
else return BadRequest(response.Errors);
|
||||
}
|
||||
[HttpPut("UserLoginVerification/{ID}/{Code}")]
|
||||
public async Task<ActionResult<AuthResponse>> UserLoginVerification(int ID,string Code)
|
||||
{
|
||||
var response = await _verificationService.VerificationCode(new Common.Dtos.Verification.ConfirmedCodeDto()
|
||||
{ code =Code,codeType=Common.Enums.VerificationCodeType.Login,Id=ID});
|
||||
|
||||
if (response.Success) return Ok(response.Value);
|
||||
else return BadRequest(response.Errors);
|
||||
}
|
||||
[HttpGet("IsOnline")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> IsOnline()
|
||||
{
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user