mirror of
https://github.com/spring-projects/spring-security.git
synced 2026-05-07 08:01:52 +00:00
Update anonymous.adoc
make the example code return the same thing for the do and don't do. Signed-off-by: nobletrout <nobletrout@gmail.com>
This commit is contained in:
parent
5ded04da6c
commit
555fe1f147
@ -148,7 +148,11 @@ Java::
|
||||
----
|
||||
@GetMapping("/")
|
||||
public String method(@CurrentSecurityContext SecurityContext context) {
|
||||
return context.getAuthentication().getName();
|
||||
if (context.getAuthentication() instanceOf AnonymousAuthenticationToken) {
|
||||
return "anonymous"
|
||||
} else {
|
||||
return "not anonymous"
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
@ -157,7 +161,12 @@ Kotlin::
|
||||
[source,kotlin,role="secondary"]
|
||||
----
|
||||
@GetMapping("/")
|
||||
fun method(@CurrentSecurityContext context : SecurityContext) : String =
|
||||
context!!.authentication!!.name
|
||||
fun method(@CurrentSecurityContext context : SecurityContext) : String {
|
||||
return if (context!!.authentication is AnonymousAuthenticationToken) {
|
||||
"anonymous"
|
||||
} else {
|
||||
"not anonymous"
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user