添加项目文件。
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using IdentityService.Domain;
|
||||
using IdentityService.WebApi.Applications.Auth;
|
||||
using IdentityService.WebApi.Applications.Dtos;
|
||||
using IdentityService.WebApi.Applications.Dtos.Common;
|
||||
using IM.Commons;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace IdentityService.WebApi.Controllers.Auth
|
||||
{
|
||||
[Route("/api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
private readonly AuthService authService;
|
||||
private readonly IIdRepository idRepository;
|
||||
|
||||
public AuthController(AuthService authService, IIdRepository idRepository)
|
||||
{
|
||||
this.authService = authService;
|
||||
this.idRepository = idRepository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesDefaultResponseType(typeof(Result<LoginResponse>))]
|
||||
public async Task<IActionResult> Login([FromBody] LoginRequest loginRequest)
|
||||
{
|
||||
return Ok(await authService.LoginAsync(loginRequest.UserName, loginRequest.Password));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesDefaultResponseType(typeof(Result<UserResponse>))]
|
||||
public async Task<IActionResult> Register([FromBody] RegisterRequest registerRequest)
|
||||
{
|
||||
return Ok(await authService.RegisterAsync(registerRequest.UserName, registerRequest.Password, registerRequest.NickName));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesDefaultResponseType(typeof(Result<LoginResponse>))]
|
||||
public async Task<IActionResult> Refresh([FromBody] RefreshRequest refreshRequest)
|
||||
{
|
||||
return Ok(await authService.RefreshAsync(refreshRequest.RefreshToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user