Commit f2518ab7 authored by zengtianlai3's avatar zengtianlai3

解决账号密码明文传输

parent 7371e857
...@@ -13,6 +13,7 @@ import iot.sixiang.license.model.BaseResult; ...@@ -13,6 +13,7 @@ import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.vo.LoginVo; import iot.sixiang.license.model.vo.LoginVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -49,7 +50,9 @@ public class LoginController { ...@@ -49,7 +50,9 @@ public class LoginController {
public ResResult<LoginVo> login(@RequestParam("userName") String userName, @RequestParam("password") String password) { public ResResult<LoginVo> login(@RequestParam("userName") String userName, @RequestParam("password") String password) {
for (LoginUser dbUser : userMap.values()) { for (LoginUser dbUser : userMap.values()) {
if (dbUser.getUserName().equals(userName) && dbUser.getPassword().equals(password)) { String account = dbUser.getUserName();
String psw = account + dbUser.getPassword();
if (DigestUtils.md5DigestAsHex(account.getBytes()).equals(userName) && DigestUtils.md5DigestAsHex(psw.getBytes()).equals(password)) {
log.info("登录成功!生成token!"); log.info("登录成功!生成token!");
String token = JwtUtil.createToken(dbUser); String token = JwtUtil.createToken(dbUser);
LoginVo loginVo = new LoginVo(); LoginVo loginVo = new LoginVo();
...@@ -62,6 +65,13 @@ public class LoginController { ...@@ -62,6 +65,13 @@ public class LoginController {
return ResResult.failed().setMsgValue("用户名或密码错误"); return ResResult.failed().setMsgValue("用户名或密码错误");
} }
public static void main(String[] args) {
String account = "root";
String password = "root123456";
System.out.println(DigestUtils.md5DigestAsHex(account.getBytes()));
System.out.println(DigestUtils.md5DigestAsHex(password.getBytes()));
}
@ApiOperation(value = "注销接口", notes = "注销接口") @ApiOperation(value = "注销接口", notes = "注销接口")
@GetMapping("logout") @GetMapping("logout")
@MyLog(title = "注销", businessType = BusinessType.OTHER) @MyLog(title = "注销", businessType = BusinessType.OTHER)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment