SysAuthAppService.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 用户登录认证服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "sys-auth")]
  7. [Route("sys/auth")]
  8. public class SysAuthAppService(ISysAuthService authService) : IDynamicApiController
  9. {
  10. private readonly ISysAuthService _authService = authService;
  11. /// <summary>
  12. /// 账户密码登录
  13. /// </summary>
  14. /// <param name="input"></param>
  15. /// <returns></returns>
  16. [AllowAnonymous]
  17. public async Task<AuthOutput> LoginByAccount(LoginInput input)
  18. {
  19. return await _authService.LoginByAccount(input);
  20. }
  21. /// <summary>
  22. /// 退出登录
  23. /// </summary>
  24. /// <returns></returns>
  25. [AllowAnonymous]
  26. public async Task Logout()
  27. {
  28. await _authService.Logout();
  29. }
  30. /// <summary>
  31. /// 获取当前登录用户信息
  32. /// </summary>
  33. /// <returns></returns>
  34. public async Task<LoginOutput> GetLoginUser()
  35. {
  36. return await _authService.GetLoginUser();
  37. }
  38. /// <summary>
  39. /// 获取图形验证码
  40. /// </summary>
  41. /// <returns></returns>
  42. [AllowAnonymous, DisableOpLog]
  43. public async Task<GeneralCaptchaOutput> GetCaptcha()
  44. {
  45. return await _authService.GetCaptcha();
  46. }
  47. /// <summary>
  48. /// 校验图形验证码
  49. /// </summary>
  50. /// <param name="input"></param>
  51. /// <returns></returns>
  52. [AllowAnonymous, DisableOpLog]
  53. public async Task<GeneralCaptchaOutput> VerifyCaptcha(GeneralCaptchaInput input)
  54. {
  55. return await _authService.VerifyCaptcha(input);
  56. }
  57. /// <summary>
  58. /// 获取临时密码
  59. /// </summary>
  60. /// <param name="input"></param>
  61. /// <returns></returns>
  62. [AllowAnonymous, DisableOpLog]
  63. [HttpPost]
  64. public List<string> GetTempPassword([Required] List<string> input)
  65. {
  66. return _authService.GetTempPassword(input);
  67. }
  68. [AllowAnonymous, DisableOpLog]
  69. public string GetPbkdf2(string pwd)
  70. {
  71. return PBKDF2Encryption.Encrypt(pwd);
  72. }
  73. [AllowAnonymous, DisableOpLog]
  74. public bool ComparePbkdf2(string pwd, string pbpwd)
  75. {
  76. return PBKDF2Encryption.Compare(pwd, pbpwd);
  77. }
  78. }