コード例 #1
0
ファイル: Logout.java プロジェクト: harshadptl/lumify
 @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
ファイル: Login.java プロジェクト: boiler256/lumify
  @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);
  }