jeecgboot修改身份认证为私有第三方统一身份认证

本教程为jeecgboot修改其认证为第三方统一身份认证

目录

    • 前端
    • 后端

前端

修改登录加密方法(修改用户名密码登录为密文传输)
this.$tools.encrypt()为自定义
/src/views/user/LoginAccount.vue

 //账号密码登录
      handleLogin(rememberMe){
        this.validateFields([ 'username', 'password', 'inputCode' ], (err)=>{
          if(!err){
            let loginParams = {
              
              username: this.$tools.encrypt(this.model.username),
              password: this.$tools.encrypt(this.model.password),
              captcha: this.model.inputCode,
              checkKey: this.currdatetime,
              remember_me: rememberMe,
            }

/src/api/index.js
修改login为第三方login接口

const api = {
    Login: '/userlogin/loginwithusername',

/src/api/login.js
修改login为第三方login接口

export function login(parameter) {
  return axios({
    url: '/userlogin/loginwithusername',
    method: 'post',
    data: parameter
  })
}

后端

/LoginController.java


@Slf4j
@Api(tags = "用户登录")
@RestController
//@EnableScheduling
@RequestMapping("/userlogin")
public class LoginController {
    @Autowired
    UserLoginForService userLoginForService;
//    @RequestLimit(count = 3)
    @AutoLog(value = "用户登录")
    @ApiOperation("用户登录(第三方统一认证)")
    @PostMapping(value = "/loginwithusername")
    public Result<?> loginwithusername(
            HttpServletRequest request,
            @RequestBody JSONObject jsonObject
    ) throws IOException, ParseException {
//        System.out.println("jsonObject");
//        System.out.println(jsonObject);
        String username = jsonObject.getString("username");
        String password = jsonObject.getString("password");
        if(username==null||password==null){
            return Result.err(400001);
        }else {
            String res = userLoginForService.loginwithusername(username,password);
//            System.out.println(res);
            Result res2 = new Result<>();
            System.out.println(res);
            res2.setResult(JSONObject.parseObject(res));
            System.out.println(res2);
            return Result.OK(JSONObject.parseObject(res));
        }
    }


}

	//统一身份认证()
	@Override
	public String loginwithusername(String username, String password) throws IOException, ParseException {
//读取redis
	//发出内容
	//接收内容,解析内容
	//设置redis
	//返回数据
	}

你可能感兴趣的:(javaweb,jeecg,vue,java,前端,开发语言)