using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using ERP.Core.Service; using ERP.Core.Dto; using ERP.Core.Emum; using ERP.Framework.Config; using ERP.Framework.Constants; using ERP.Framework.WebApi; //using Swashbuckle.AspNetCore.Annotations; namespace ERP.Core.Controller { [Route("/")] public class AuthController : BaseController { private readonly IConfiguration _configuration; private readonly AuthService _authService; public AuthController(IConfiguration configuration, AuthService authService) { _configuration = configuration; _authService = authService; } [HttpPost("/login")] //[SwaggerOperation(Description = "登录接口", Summary = "Login")] public async Task LoginAsync([FromBody] LoginBody form) { var m = GetType().Name; var securityConfig = _configuration.GetSection(FrameworkConstant.SecurityConfig).Get() ?? new SecurityConfig(); var loginUser = _authService.GetLoginUser(securityConfig, form.LoginName, form.Password); //var jwtToken = LoginHelper.LoginByDevice(loginUser, securityConfig, DeviceEnum.Web); //var isFirst = loginUser.UserStatus == API.Core.Enum.UserStatusEnum.New; //var isPasswordExpire = loginUser.PasswordExpirationTime >= DateTime.Now; //Todo 记录登录日志 return Success(new { //token = jwtToken.Token, //expire = jwtToken.Expire, //userInfo = loginUser, //isFirst, //isPasswordExpire, }); } } }