Skip to content

Commit c901b42

Browse files
committed
add postHandle
1 parent fba1866 commit c901b42

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

springboot-starter-security-jwt/src/main/java/com/codingapi/springboot/security/AutoConfiguration.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import com.codingapi.springboot.security.configurer.HttpSecurityConfigurer;
44
import com.codingapi.springboot.security.controller.VersionController;
5+
import com.codingapi.springboot.security.dto.request.LoginRequest;
56
import com.codingapi.springboot.security.filter.*;
67
import com.codingapi.springboot.security.jwt.Jwt;
78
import com.codingapi.springboot.security.properties.SecurityJwtProperties;
9+
import jakarta.servlet.http.HttpServletRequest;
10+
import jakarta.servlet.http.HttpServletResponse;
811
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
912
import org.springframework.boot.context.properties.ConfigurationProperties;
1013
import org.springframework.context.annotation.Bean;
@@ -57,8 +60,17 @@ public PasswordEncoder passwordEncoder() {
5760
@Bean
5861
@ConditionalOnMissingBean
5962
public SecurityLoginHandler securityLoginHandler(){
60-
return (request, response, handler) -> {
61-
};
63+
return new SecurityLoginHandler() {
64+
@Override
65+
public void preHandle(HttpServletRequest request, HttpServletResponse response, LoginRequest handler) throws Exception {
66+
67+
}
68+
69+
@Override
70+
public void postHandle(HttpServletRequest request, HttpServletResponse response, LoginRequest handler) {
71+
72+
}
73+
};
6274
}
6375

6476

springboot-starter-security-jwt/src/main/java/com/codingapi/springboot/security/filter/MyLoginFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ protected void successfulAuthentication(HttpServletRequest request, HttpServletR
8484
String content = JSONObject.toJSONString(SingleResponse.of(login));
8585
IOUtils.write(content, response.getOutputStream(), StandardCharsets.UTF_8);
8686

87+
loginHandler.postHandle(request,response,loginRequest);
8788
LoginRequestContext.getInstance().clean();
89+
8890
}
8991

9092

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.codingapi.springboot.security.filter;
22

33
import com.codingapi.springboot.security.dto.request.LoginRequest;
4-
54
import jakarta.servlet.http.HttpServletRequest;
65
import jakarta.servlet.http.HttpServletResponse;
76

87
public interface SecurityLoginHandler {
98

10-
void preHandle(HttpServletRequest request, HttpServletResponse response, LoginRequest handler) throws Exception;
9+
void preHandle(HttpServletRequest request, HttpServletResponse response, LoginRequest handler) throws Exception;
10+
11+
void postHandle(HttpServletRequest request, HttpServletResponse response, LoginRequest handler);
12+
1113
}

0 commit comments

Comments
 (0)