登录注册优化

main
tamguo 7 years ago
parent 1f1e29a46c
commit 7cc44cd9ac

@ -32,14 +32,15 @@ public class PaperCrawler {
private final String COURSE_ID = "likeshuxue"; private final String COURSE_ID = "likeshuxue";
// 110000 北京 | 310000 上海 | 500000 重庆 | 120100 天津 | 370000 山东 | 410000 河南 | 420000 湖北 | 320000 江苏 | 330000 浙江 // 110000 北京 | 310000 上海 | 500000 重庆 | 120100 天津 | 370000 山东 | 410000 河南 | 420000 湖北 | 320000 江苏 | 330000 浙江
// 140000 山西 | 350000 福建 | 340000 安徽 | 220000 吉林 | 150000 内蒙古 | 640000 宁夏 | 650000 新疆 | 广西 450000 | 210000 辽宁 // 140000 山西 | 350000 福建 | 340000 安徽 | 220000 吉林 | 150000 内蒙古 | 640000 宁夏 | 650000 新疆 | 广西 450000 | 210000 辽宁
// 230000 黑龙江 | 610000 陕西 | 360000 江西 | 440000 广东 | 430000 湖南 | 460000 海南 | 530000 云南 // 230000 黑龙江 | 610000 陕西 | 360000 江西 | 440000 广东 | 430000 湖南 | 460000 海南 | 530000 云南 | 510000 四川 | 630000 青海
private final String AREA_ID = "530000"; // 620000 甘肃
private final String AREA_ID = "620000";
// 年份 // 年份
private final String YEAR = "2015"; private final String YEAR = "2015";
// 真题试卷 类型(1:真题试卷,2:模拟试卷,3:押题预测,4:名校精品) // 真题试卷 类型(1:真题试卷,2:模拟试卷,3:押题预测,4:名校精品)
private final String PAPER_TYPE = "3"; private final String PAPER_TYPE = "3";
// 开始采集的URL // 开始采集的URL
private final String START_URL = "https://tiku.baidu.com/tikupc/paperlist/1bfd700abb68a98271fefa04-16-2-2015-1597-1-download"; private final String START_URL = "https://tiku.baidu.com/tikupc/paperlist/1bfd700abb68a98271fefa04-16-2-2015-1757-1-download";
private RunData runData; private RunData runData;

@ -39,11 +39,5 @@ public class ShiroUtils {
public static void logout() { public static void logout() {
SecurityUtils.getSubject().logout(); SecurityUtils.getSubject().logout();
} }
public static String getKaptcha(String key) {
String kaptcha = getSessionAttribute(key).toString();
// getSession().removeAttribute(key);
return kaptcha;
}
} }

@ -26,12 +26,12 @@ import com.tamguo.utils.ShiroUtils;
public class LoginController { public class LoginController {
@RequestMapping("captcha.jpg") @RequestMapping("captcha.jpg")
public void captcha(HttpServletResponse response) throws ServletException, IOException { public void captcha(HttpServletResponse response , HttpSession session) throws ServletException, IOException {
response.setHeader("Cache-Control", "no-store, no-cache"); response.setHeader("Cache-Control", "no-store, no-cache");
response.setContentType("image/jpeg"); response.setContentType("image/jpeg");
String a = CaptchaUtils.generateCaptcha(response.getOutputStream()); String a = CaptchaUtils.generateCaptcha(response.getOutputStream());
ShiroUtils.setSessionAttribute(SystemConstant.KAPTCHA_SESSION_KEY, a); session.setAttribute(SystemConstant.KAPTCHA_SESSION_KEY, a);
} }
@RequestMapping(value = "/login.html", method = RequestMethod.GET) @RequestMapping(value = "/login.html", method = RequestMethod.GET)
@ -47,7 +47,7 @@ public class LoginController {
if(StringUtils.isEmpty(verifyCode)) { if(StringUtils.isEmpty(verifyCode)) {
result = Result.result(202, null, "请输入验证码"); result = Result.result(202, null, "请输入验证码");
} else if(StringUtils.isNotEmpty(verifyCode)){ } else if(StringUtils.isNotEmpty(verifyCode)){
String kaptcha = ShiroUtils.getKaptcha(SystemConstant.KAPTCHA_SESSION_KEY); String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString();
if (!verifyCode.equalsIgnoreCase(kaptcha)) { if (!verifyCode.equalsIgnoreCase(kaptcha)) {
result = Result.result(205, null, "验证码错误"); result = Result.result(205, null, "验证码错误");
} else { } else {
@ -82,7 +82,7 @@ public class LoginController {
if(StringUtils.isEmpty(captcha)) { if(StringUtils.isEmpty(captcha)) {
result = Result.result(204, null, "请输入验证码"); result = Result.result(204, null, "请输入验证码");
} else if(StringUtils.isNotEmpty(captcha)){ } else if(StringUtils.isNotEmpty(captcha)){
String kaptcha = ShiroUtils.getKaptcha(SystemConstant.KAPTCHA_SESSION_KEY); String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString();
if (!captcha.equalsIgnoreCase(kaptcha)) { if (!captcha.equalsIgnoreCase(kaptcha)) {
result = Result.result(205, null, "验证码错误"); result = Result.result(205, null, "验证码错误");
}else { }else {

@ -1,5 +1,6 @@
package com.tamguo.web.member; package com.tamguo.web.member;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -10,7 +11,6 @@ import org.springframework.web.servlet.ModelAndView;
import com.tamguo.common.utils.Result; import com.tamguo.common.utils.Result;
import com.tamguo.common.utils.SystemConstant; import com.tamguo.common.utils.SystemConstant;
import com.tamguo.modules.member.service.IMemberService; import com.tamguo.modules.member.service.IMemberService;
import com.tamguo.utils.ShiroUtils;
@Controller @Controller
public class PasswordController { public class PasswordController {
@ -25,9 +25,9 @@ public class PasswordController {
} }
@RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST) @RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST)
public ModelAndView submitConfirmAccount(String username , String veritycode , ModelAndView model){ public ModelAndView submitConfirmAccount(String username , String veritycode , ModelAndView model , HttpSession session){
Result result = iMemberService.confirmAccount(username, veritycode); Result result = iMemberService.confirmAccount(username, veritycode);
String kaptcha = ShiroUtils.getKaptcha(SystemConstant.KAPTCHA_SESSION_KEY); String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString();
if (!veritycode.equalsIgnoreCase(kaptcha)) { if (!veritycode.equalsIgnoreCase(kaptcha)) {
result = Result.result(202, null, "验证码错误"); result = Result.result(202, null, "验证码错误");
} }

Loading…
Cancel
Save