withAnonymousUser<T> function

Future<T> withAnonymousUser<T>(
  1. FutureOr<T> body()
)

Runs body as an anonymous user (anonymousUser with ROLE_ANONYMOUS), as the web starter sets for a request without a login, and returns its result.

Spring (Java): @WithAnonymousUser.

Implementation

Future<T> withAnonymousUser<T>(FutureOr<T> Function() body) =>
    withAuthentication(
      body,
      AnonymousAuthenticationToken(
        'key',
        'anonymousUser',
        AuthorityUtils.createAuthorityList(['ROLE_ANONYMOUS']),
      ),
    );