You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, you can use Spring's `@EventListener` support:
19
32
20
-
[source,java]
33
+
====
34
+
.Java
35
+
[source,java,role="primary"]
21
36
----
22
37
@Component
23
38
public class AuthenticationEvents {
@@ -33,6 +48,24 @@ public class AuthenticationEvents {
33
48
}
34
49
----
35
50
51
+
.Kotlin
52
+
[source,kotlin,role="secondary"]
53
+
----
54
+
@Component
55
+
class AuthenticationEvents {
56
+
@EventListener
57
+
fun onSuccess(success: AuthenticationSuccessEvent?) {
58
+
// ...
59
+
}
60
+
61
+
@EventListener
62
+
fun onFailure(failures: AbstractAuthenticationFailureEvent?) {
63
+
// ...
64
+
}
65
+
}
66
+
----
67
+
====
68
+
36
69
While similar to `AuthenticationSuccessHandler` and `AuthenticationFailureHandler`, these are nice in that they can be used independently from the servlet API.
37
70
38
71
=== Adding Exception Mappings
@@ -56,7 +89,9 @@ The publisher does an exact `Exception` match, which means that sub-classes of t
56
89
57
90
To that end, you may want to supply additional mappings to the publisher via the `setAdditionalExceptionMappings` method:
58
91
59
-
[source,java]
92
+
====
93
+
.Java
94
+
[source,java,role="primary"]
60
95
----
61
96
@Bean
62
97
public AuthenticationEventPublisher authenticationEventPublisher
@@ -71,11 +106,28 @@ public AuthenticationEventPublisher authenticationEventPublisher
0 commit comments