gao
2020-05-27 d89ecce959bc93db298a29617b3d7337b53ecea8
src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.common.system.controller;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
@@ -60,12 +61,8 @@
    @ApiOperation(value = "登陆接口", notes = "登陆接口")
    @PostMapping("/login")
    public Result login(@RequestBody @Validated LoginDto loginDto) {
        // 使用md5加密前端传来的密码
        Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA);
        byte[] pwdByte = sign.sign(loginDto.getPassword().getBytes());
        // 将账号密码交给spring security验证,并调用userServiceDetails
        UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(loginDto.getUsername(), loginDto.getPassword());
        UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(loginDto.getUsername(), SecureUtil.md5(loginDto.getPassword()));
        Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authToken);
        // 获取当前验证过后的用户