Browse Source

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>
pull/16795/head
nobletrout 11 months ago committed by Steve Riesenberg
parent
commit
555fe1f147
  1. 15
      docs/modules/ROOT/pages/servlet/authentication/anonymous.adoc

15
docs/modules/ROOT/pages/servlet/authentication/anonymous.adoc

@ -148,7 +148,11 @@ Java::
---- ----
@GetMapping("/") @GetMapping("/")
public String method(@CurrentSecurityContext SecurityContext context) { 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"] [source,kotlin,role="secondary"]
---- ----
@GetMapping("/") @GetMapping("/")
fun method(@CurrentSecurityContext context : SecurityContext) : String = fun method(@CurrentSecurityContext context : SecurityContext) : String {
context!!.authentication!!.name return if (context!!.authentication is AnonymousAuthenticationToken) {
"anonymous"
} else {
"not anonymous"
}
}
---- ----
====== ======

Loading…
Cancel
Save