|
|
|
@ -3,18 +3,16 @@ package com.main.woka.Web.Controller; |
|
|
|
import cn.dev33.satoken.stp.StpUtil; |
|
|
|
import com.main.woka.Common.core.AjaxResult; |
|
|
|
import com.main.woka.Common.util.PasswordUtil; |
|
|
|
import com.main.woka.Web.Dao.GraphQuery; |
|
|
|
import com.main.woka.Web.Dao.KcUser; |
|
|
|
import com.main.woka.Web.Mapper.KcUserMapper; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.Cookie; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/login") |
|
|
|
public class LoginController extends BaseController{ |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -32,29 +30,33 @@ public class LoginController extends BaseController{ |
|
|
|
if(kcUser.getUserName()==null || kcUser.getUserName().equals("")){ |
|
|
|
return AjaxResult.error("请填写用户名"); |
|
|
|
} |
|
|
|
System.out.println(); |
|
|
|
|
|
|
|
//判断是不是有密码
|
|
|
|
if(kcUser.getPassword()==null || kcUser.getPassword().equals("")){ |
|
|
|
return AjaxResult.error("请填写密码"); |
|
|
|
} |
|
|
|
|
|
|
|
kcUser.setPassword(null); |
|
|
|
KcUser selectUser = new KcUser(); |
|
|
|
selectUser.setUserName(kcUser.getUserName()); |
|
|
|
|
|
|
|
//查询这个人
|
|
|
|
List<KcUser> list = kcUserMapper.selectUser(kcUser); |
|
|
|
List<KcUser> list = kcUserMapper.selectUser(selectUser); |
|
|
|
KcUser loginUser = list.get(0); |
|
|
|
String userPassword = loginUser.getPassword();//获取这个用户的加密后的密码
|
|
|
|
|
|
|
|
|
|
|
|
//判断密码是否正确
|
|
|
|
String password = kcUser.getPassword(); |
|
|
|
String MD5 = passwordUtil.hashPassword(password); |
|
|
|
String password1 = kcUser.getPassword(); |
|
|
|
System.out.println(password1); |
|
|
|
String MD5 = passwordUtil.hashPassword(password1); |
|
|
|
|
|
|
|
if(!userPassword.equals(MD5)){ |
|
|
|
return AjaxResult.error("密码错误"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
StpUtil.login(kcUser.getId());//登录
|
|
|
|
StpUtil.login(loginUser.getId());//登录
|
|
|
|
|
|
|
|
// 获取当前登录的Token(假设你使用的是默认的Token名称 "satoken")
|
|
|
|
String token = StpUtil.getTokenValue(); |
|
|
|
@ -71,7 +73,9 @@ public class LoginController extends BaseController{ |
|
|
|
|
|
|
|
// 将Cookie添加到响应中
|
|
|
|
response.addCookie(cookie); |
|
|
|
ajaxResult.put("info",kcUser); |
|
|
|
loginUser.setPassword(null); |
|
|
|
ajaxResult.put("info",loginUser); |
|
|
|
|
|
|
|
return ajaxResult; |
|
|
|
} |
|
|
|
|
|
|
|
|