| | |
| | | return Json(Service.Login(loginInfo)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Swagger 登录接口 |
| | | /// </summary> |
| | | /// <param name="loginRequest">登录请求</param> |
| | | /// <returns>登录结果</returns> |
| | | [HttpPost, Route("swgLogin"), AllowAnonymous] |
| | | public dynamic SwgLogin([FromBody] SwaggerLoginRequest loginRequest) |
| | | { |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | // 记录异常日志 |
| | | return new { result = false, message = ex.Message }; |
| | | } |
| | | |
| | | return new { result = false }; |
| | |
| | | return Json(Service.ModifyPwd(oldPwd, newPwd)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取验证码 |
| | | /// 注意:当前版本使用固定验证码 "1234" 用于测试 |
| | | /// </summary> |
| | | /// <returns>验证码图片和唯一标识</returns> |
| | | [HttpGet, Route("getVierificationCode"), AllowAnonymous] |
| | | public IActionResult GetVierificationCode() |
| | | { |
| | | //var html = MiniProfiler.Current.RenderIncludes(_httpContextAccessor.HttpContext); |
| | | string code = "1234" /*VierificationCode.RandomText()*/; |
| | | // TODO: 生产环境应启用真实验证码生成 |
| | | // var html = MiniProfiler.Current.RenderIncludes(_httpContextAccessor.HttpContext); |
| | | string code = "1234"; // 测试用固定验证码,生产环境应使用 VierificationCode.RandomText() |
| | | var data = new |
| | | { |
| | | img = VierificationCode.CreateBase64Imgage(code), |
| | |
| | | { |
| | | return WebResponseContent.Instance.OK(data: JwtHelper.SerializeJwt(code)); |
| | | } |
| | | /// <summary> |
| | | /// 替换Token(刷新令牌) |
| | | /// </summary> |
| | | /// <returns>新的Token</returns> |
| | | [HttpPost, Route("replaceToken")] |
| | | public WebResponseContent ReplaceToken() |
| | | { |
| | |
| | | string token = App.User.GetToken(); |
| | | if (string.IsNullOrEmpty(token)) |
| | | { |
| | | return responseContent = WebResponseContent.Instance.Error("token无效,请重新登录!"); |
| | | return responseContent.Error("Token无效,请重新登录!"); |
| | | } |
| | | TokenModelJwt tokenModelJwt = new TokenModelJwt() |
| | | { |
| | |
| | | string newToken = JwtHelper.IssueJwt(tokenModelJwt); |
| | | |
| | | App.User.UpdateToke(newToken, App.User.UserId); |
| | | return responseContent = WebResponseContent.Instance.OK(data: newToken); |
| | | return responseContent.OK(data: newToken); |
| | | } |
| | | catch (Exception ex) |
| | | { |