Пример #1
0
 @Override
 public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain)
     throws Exception {
   CurrentUser.clear(request);
   JSONObject json = new JSONObject();
   json.put("status", "ok");
   respondWithJson(response, json);
 }
Пример #2
0
  @Override
  public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain)
      throws Exception {
    final String username = UrlUtils.urlDecode(request.getParameter("username"));

    User user = getUserRepository().findByUsername(username);
    if (user == null) {
      // For form based authentication, username and displayName will be the same
      String randomPassword = UserRepository.createRandomPassword();
      user = getUserRepository().addUser(username, username, null, randomPassword, new String[0]);
    }
    getUserRepository().recordLogin(user, AuthenticationHandler.getRemoteAddr(request));

    CurrentUser.set(request, user.getUserId(), user.getUsername());
    JSONObject json = new JSONObject();
    json.put("status", "OK");
    respondWithJson(response, json);
  }