拦截器

This commit is contained in:
2023-12-22 11:47:07 +08:00
parent 39048bbcfc
commit a35f4a6527
6 changed files with 36 additions and 9 deletions

View File

@@ -32,6 +32,7 @@ public class UserController {
//发送邮箱验证码
@GetMapping("/sendActiveCode")
public String sendActiveCode(HttpSession session, User user){
String activecode=userService.sendEmailActivecode(user);
session.setAttribute(user.getUserEmail(),activecode);
return "发送验证码成功!";
@@ -58,10 +59,15 @@ public class UserController {
}
return "注册成功!";
}
@RequestMapping("/login")
@RequestMapping(value = "/login",produces = {"application/json;charset=UTF-8"})
public Map<String,Object>login(User user,String code,HttpSession session){
Map<String,Object> map=new HashMap<>();
String sessionCode = (String) session.getAttribute(RandomValidateCode.RANDOMVALIDATECODE);
if (sessionCode==null){
map.put("msg","验证码空的");
return map;
}
if (!sessionCode.equals(code)){
map.put("msg","验证码错误");
return map;
@@ -109,7 +115,9 @@ public class UserController {
@RequestMapping("/findThePassword")
public Map<String,Object> findThePassword(User user,HttpSession session){
Map<String,Object> map=new HashMap<>();
User user1=userService.selectUserAlreadyExist(user);
System.out.println(user1);
if (user1==null){
map.put("msg","无此邮箱");
return map;