AuthController.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Microsoft.AspNetCore.Mvc;
  2. using Microsoft.Extensions.Configuration;
  3. using ERP.Core.Service;
  4. using ERP.Core.Dto;
  5. using ERP.Core.Emum;
  6. using ERP.Framework.Config;
  7. using ERP.Framework.Constants;
  8. using ERP.Framework.WebApi;
  9. //using Swashbuckle.AspNetCore.Annotations;
  10. namespace ERP.Core.Controller
  11. {
  12. [Route("/")]
  13. public class AuthController : BaseController
  14. {
  15. private readonly IConfiguration _configuration;
  16. private readonly AuthService _authService;
  17. public AuthController(IConfiguration configuration, AuthService authService)
  18. {
  19. _configuration = configuration;
  20. _authService = authService;
  21. }
  22. [HttpPost("/login")]
  23. //[SwaggerOperation(Description = "登录接口", Summary = "Login")]
  24. public async Task<IActionResult> LoginAsync([FromBody] LoginBody form)
  25. {
  26. var m = GetType().Name;
  27. var securityConfig = _configuration.GetSection(FrameworkConstant.SecurityConfig).Get<SecurityConfig>() ?? new SecurityConfig();
  28. var loginUser = _authService.GetLoginUser(securityConfig, form.LoginName, form.Password);
  29. //var jwtToken = LoginHelper.LoginByDevice(loginUser, securityConfig, DeviceEnum.Web);
  30. //var isFirst = loginUser.UserStatus == API.Core.Enum.UserStatusEnum.New;
  31. //var isPasswordExpire = loginUser.PasswordExpirationTime >= DateTime.Now;
  32. //Todo 记录登录日志
  33. return Success(new
  34. {
  35. //token = jwtToken.Token,
  36. //expire = jwtToken.Expire,
  37. //userInfo = loginUser,
  38. //isFirst,
  39. //isPasswordExpire,
  40. });
  41. }
  42. }
  43. }