From f09fa3541ad18c00f30707f592f16d18a0537f77 Mon Sep 17 00:00:00 2001 From: manailin <261030956@qq.com> Date: 星期二, 17 八月 2021 21:54:51 +0800 Subject: [PATCH] [新增]添加监控依赖包 --- springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/handel/UserLoginSuccessHandler.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/handel/UserLoginSuccessHandler.java b/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/handel/UserLoginSuccessHandler.java new file mode 100644 index 0000000..0e9314e --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/handel/UserLoginSuccessHandler.java @@ -0,0 +1,42 @@ +package com.panzhihua.auth.handel; + +import com.panzhihua.common.utlis.JWTTokenUtil; +import com.panzhihua.common.model.vos.LoginUserInfoVO; +import com.panzhihua.common.utlis.ResultUtil; +import com.panzhihua.common.constants.TokenConstant; +import com.panzhihua.common.model.vos.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @program: springcloud_k8s_panzhihuazhihuishequ + * @description: 登录成功 + * @author: huang.hongfa weixin hhf9596 qq 959656820 + * @create: 2020-11-24 15:23 + **/ +@Slf4j +public class UserLoginSuccessHandler implements AuthenticationSuccessHandler { + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authentication) throws IOException, ServletException { + log.info("登录成功"); + } + + @Override + public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { + log.info("登录成功"); + // 组装JWT + LoginUserInfoVO loginUserInfoVO = (LoginUserInfoVO) authentication.getPrincipal(); + String token = JWTTokenUtil.generateToken(loginUserInfoVO); + token = TokenConstant.TOKEN_PRE + token; + // 封装返回参数 + R<String> ok = R.ok(token); + ResultUtil.responseJson(httpServletResponse,ok); + } +} -- Gitblit v1.7.1