code: @Override
      public final Optional<RedirectionAction> redirect(final WebContext context) {
          init();
          // it's an AJAX request -> appropriate action
          if (ajaxRequestResolver.isAjax(context)) {
              final HttpAction httpAction = ajaxRequestResolver.buildAjaxResponse(context, redirectionActionBuilder);
              logger.debug("AJAX request detected -> returning " + httpAction + " for " + context.getFullRequestURL());
              cleanRequestedUrl(context);
              throw httpAction;
          }
          // authentication has already been tried -> unauthorized
          final Optional<String> attemptedAuth = (Optional<String>) context.getSessionStore()
              .get(context, getName() + ATTEMPTED_AUTHENTICATION_SUFFIX);
          if (attemptedAuth.isPresent() && !"".equals(attemptedAuth.get())) {
              cleanAttemptedAuthentication(context);
              cleanRequestedUrl(context);
              throw UnauthorizedAction.INSTANCE;
          }
  
          return redirectionActionBuilder.redirect(context);
      }
docs: <p>If an authentication has already been tried for this client and has failed (<code>null</code> credentials) or if the request is
  an AJAX one, an unauthorized response is thrown instead of a "redirection".</p>
  
  @param context context
  @return the "redirection" action