public IHttpActionResult Check(string name, [FromBody] CaptchaInfo captchaInfo) { try { var code = CookieUtils.GetCookie("SS-" + name); if (string.IsNullOrEmpty(code) || CacheUtils.Exists($"SiteServer.API.Controllers.V1.CaptchaController.{code}")) { return(BadRequest("验证码已超时,请点击刷新验证码!")); } CookieUtils.Erase("SS-" + name); CacheUtils.InsertMinutes($"SiteServer.API.Controllers.V1.CaptchaController.{code}", true, 10); if (!StringUtils.EqualsIgnoreCase(code, captchaInfo.Captcha)) { return(BadRequest("验证码不正确,请重新输入!")); } return(Ok(new { Value = true })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult Check([FromBody] CheckRequest request) { try { var code = CookieUtils.GetCookie(CookieName); if (string.IsNullOrEmpty(code) || CacheUtils.Exists($"{CookieName}.{code}")) { return(BadRequest("验证码已超时,请点击刷新验证码!")); } CookieUtils.Erase(CookieName); CacheUtils.InsertMinutes($"{CookieName}.{code}", true, 10); if (!StringUtils.EqualsIgnoreCase(code, request.Captcha)) { return(BadRequest("验证码不正确,请重新输入!")); } return(Ok(new { Value = true })); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void UserLogout() { UserName = null; CookieUtils.Erase(UserAccessToken); }
public void AdminLogout() { CookieUtils.Erase(AdministratorAccessToken); }
public void UserLogout() { UserInfo = null; CookieUtils.Erase(AuthKeyUserCookie); }
public void AdminLogout() { CookieUtils.Erase(AuthKeyAdminCookie); }
public void AdminLogout() { CookieUtils.Erase(Constants.AuthKeyAdminCookie); }
public IHttpActionResult Insert() { try { var request = Context.AuthenticatedRequest; var siteId = request.GetPostInt("siteId"); if (!request.IsAdminLoggin) { return(Unauthorized()); } var authCode = request.GetPostString("authCode"); var code = CookieUtils.GetCookie(CaptchaController.CookieName); if (string.IsNullOrEmpty(code) || CacheUtils.Exists($"{CaptchaController.CookieName}.{code}")) { return(BadRequest("验证码已超时,请点击刷新验证码!")); } CookieUtils.Erase(CaptchaController.CookieName); CacheUtils.InsertMinutes($"{CaptchaController.CookieName}.{code}", true, 10); if (!StringUtils.EqualsIgnoreCase(code, authCode)) { return(BadRequest("验证码不正确,请重新输入!")); } var categoryId = request.GetPostInt("categoryId"); var departmentId = request.GetPostInt("departmentId"); var categoryInfo = CategoryManager.GetCategoryInfo(siteId, categoryId); var departmentInfo = DepartmentManager.GetDepartmentInfo(siteId, departmentId); var dataInfo = new DataInfo { Id = 0, SiteId = siteId, AddDate = DateTime.Now, QueryCode = StringUtils.GetShortGuid(true), CategoryId = categoryInfo?.Id ?? 0, DepartmentId = departmentInfo?.Id ?? 0, IsCompleted = false, State = DataState.New.Value, DenyReason = string.Empty, RedoComment = string.Empty, ReplyContent = string.Empty, IsReplyFiles = false, ReplyDate = DateTime.Now, Name = request.GetPostString("name"), Gender = request.GetPostString("gender"), Phone = request.GetPostString("phone"), Email = request.GetPostString("email"), Address = request.GetPostString("address"), Zip = request.GetPostString("zip"), Title = request.GetPostString("title"), Content = request.GetPostString("content"), CategoryName = categoryInfo == null ? string.Empty : categoryInfo.CategoryName, DepartmentName = departmentInfo == null ? string.Empty : departmentInfo.DepartmentName }; Main.DataRepository.Insert(dataInfo); return(Ok(new { Value = dataInfo })); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void UserLogout() { UserName = null; CookieUtils.Erase(UserAuthCookie); }
public void AdminLogout() { CookieUtils.Erase(AdministratorAuthCookie); }