コード例 #1
0
 private void process(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   String login = request.getParameter("login");
   String password = request.getParameter("password");
   if (login != null && password != null) {
     UserService service = null;
     try {
       service = new UserService();
       User user = service.findByLoginAndPassword(login, password);
       if (user != null) {
         HttpSession session = request.getSession();
         session.setAttribute("currentUser", user);
         response.sendRedirect(request.getContextPath());
       } else {
         response.sendRedirect(
             request.getContextPath()
                 + "/login.html?message="
                 + URLEncoder.encode("Имя пользователя или пароль неопознанны", "UTF-8"));
       }
     } catch (SQLException e) {
       throw new ServletException(e);
     } finally {
       if (service != null) {
         service.close();
       }
     }
   } else {
     getServletContext().getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
   }
 }
コード例 #2
0
ファイル: NotificationJob.java プロジェクト: addhub/play
 @Override
 public void run() {
   System.out.println("notifications job running");
   List<User> users = userService.queryUsers(Filters.eq("notifications", true));
   for (User user : users) {
     String query = user.getNotificationQuery();
     query = query + "&createdOn[$gt]=" + user.getLastNotificationAt();
     List<Document> documents = adService.queryAds(query);
     if (!documents.isEmpty()) {
       List<BaseAd> adsList = adService.getListAs(BaseAd.class, documents);
       twilioService.sendSMS(user.getMobile(), "New ads for your query");
       user.setLastNotificationAt(ZonedDateTime.now().toEpochSecond());
       userService.updateUser(user);
     }
   }
 }
コード例 #3
0
ファイル: UserResource.java プロジェクト: riaval/open-note
  private Representation mono() throws Exception {
    String sessionHash = getQuery().getValues("session_hash");

    User user = mUserService.getCurrentUser(sessionHash);

    return new JacksonRepresentation<UserPrivateRepresentation>(
        new UserPrivateRepresentation(user));
  }
コード例 #4
0
 /**
  * 获取用户自己的信息
  *
  * @param param
  * @return
  */
 @RequestMapping(
     value = "/myInfo.ajax",
     method = RequestMethod.POST,
     consumes = "application/json")
 @ResponseBody
 public Map myInfo(@RequestBody Map param) {
   return initResult(true, userService.myInfo(param));
 }
コード例 #5
0
 public void sendPassword() {
   try {
     userService.sendPassword();
   } catch (PostException e) {
     FacesContext.getCurrentInstance()
         .addMessage(
             null, new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), e.getMessage()));
   }
 }
コード例 #6
0
ファイル: Personal.java プロジェクト: Dingmin/leaner
 private UserInfo FindUserInfo(String SQL, Integer userId) {
   // TODO Auto-generated method stub
   List<Object> list =
       userService
           .getRepository()
           .getImply()
           .searchList(SQL, new Object[] {userId}, new BeanPropertyRowMapper(UserInfo.class));
   if (list != null && list.size() > 0) return (UserInfo) list.get(0);
   return null;
 }
コード例 #7
0
 public void login() throws IOException {
   try {
     current = userService.find(username, password);
     FacesContext.getCurrentInstance().getExternalContext().redirect("pages/read.jsf");
   } catch (PostException e) {
     FacesContext.getCurrentInstance()
         .addMessage(
             null, new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), e.getMessage()));
   }
 }
コード例 #8
0
ファイル: Personal.java プロジェクト: Dingmin/leaner
 private Degree Find_Degree(Integer user) {
   // TODO Auto-generated method stub
   List<Object> list =
       userService
           .getRepository()
           .getImply()
           .searchList(
               sql.SEARCH_DEGREE, new Object[] {user}, new BeanPropertyRowMapper(Degree.class));
   if (list != null && list.size() > 0) return (Degree) list.get(0);
   return null;
 }
コード例 #9
0
  @RequestMapping(value = "/UserLoginRequest", method = RequestMethod.POST)
  public @ResponseBody UserLoginResponse userLoginRequest(
      @RequestBody UserLoginRequest request, HttpServletRequest req) {
    UserLoginResponse response = userService.userLoginRequest(request);

    if (response.isIsAuthenicated()) {
      req.getSession().setAttribute("LOGGEDIN_USER", response.getUser());
    }

    return response;
  }
コード例 #10
0
ファイル: UserResource.java プロジェクト: riaval/open-note
  private Representation multi() throws Exception {
    String sessionHash = getQuery().getValues("session_hash");
    String search = getQuery().getValues("search");

    List<User> users = mUserService.getUsers(sessionHash, search);
    List<UserPublicRepresentation> usersResponse = new ArrayList<UserPublicRepresentation>();
    for (User each : users) {
      usersResponse.add(new UserPublicRepresentation(each));
    }

    return new JacksonRepresentation<List<UserPublicRepresentation>>(usersResponse);
  }
コード例 #11
0
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public String login(
      @RequestParam(value = "username") String username,
      @RequestParam(value = "password") String password) {
    System.out.println("username:"******",password:"******"usernotexist";
    else if (user.getPassword().equals(password)) return "loginsuccess";
    else return "loginfail";
  }
コード例 #12
0
  @RequestMapping(value = "/GetUserListByRoleRequest/{role}", method = RequestMethod.GET)
  public @ResponseBody List<User> getUserListByRoleRequest(@PathVariable("role") String role) {

    List<User> userList = null;
    try {
      userList = userService.getUserListByRoleRequest(role);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return userList;
  }
コード例 #13
0
  @RequestMapping(value = "/GetUserListRequest", method = RequestMethod.GET)
  public @ResponseBody List<User> getUserListRequest() {

    List<User> userList = null;
    try {
      userList = userService.getUserListRequest();

    } catch (Exception e) {
      e.printStackTrace();
    }

    return userList;
  }
コード例 #14
0
  @RequestMapping(value = "/GetUserByUsernameRequest/{username}", method = RequestMethod.GET)
  public @ResponseBody User getUserByUsernameRequest(@PathVariable("username") String username) {

    User user = null;
    try {
      user = userService.getUserByUsernameRequest(username);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return user;
  }
コード例 #15
0
 /**
  * 修改用户自己的资料
  *
  * @param param
  * @return
  */
 @RequestMapping(
     value = "/modifyInfo.ajax",
     method = RequestMethod.POST,
     consumes = "application/json")
 @ResponseBody
 public Map modifyInfo(@RequestBody Map param) {
   try {
     return initResult(true, userService.modifyInfo(param));
   } catch (Exception e) {
     e.printStackTrace();
     return initResult(false, e.getMessage(), "");
   }
 }
コード例 #16
0
ファイル: Personal.java プロジェクト: Dingmin/leaner
 @ResponseBody
 @RequestMapping("SearchOtherMesg")
 public List searchOtherMesg(@RequestParam("type") Integer type, HttpSession session) {
   RowMapper<other_infos> mapper = new BeanPropertyRowMapper<>(other_infos.class);
   List list =
       userService
           .getRepository()
           .getImply()
           .searchList(
               sql.SEARCH_OTHER_INFOS,
               new Object[] {(Integer) session.getAttribute("userID"), type},
               mapper);
   return list;
 }
コード例 #17
0
 /**
  * 上传用户头像,一次共大中小三张
  *
  * @param param
  * @param request
  * @return
  */
 @RequestMapping(
     value = "/modifyUserhead.ajax",
     method = RequestMethod.POST,
     consumes = "application/json")
 @ResponseBody
 public Map modifyUserhead(@RequestBody Map param, HttpServletRequest request) {
   try {
     String realPath = request.getSession().getServletContext().getRealPath("/");
     param.put("realPath", realPath);
     return initResult(true, userService.modifyUserhead(param));
   } catch (Exception e) {
     e.printStackTrace();
     return initResult(false, e.getMessage(), "");
   }
 }
コード例 #18
0
  @RequestMapping(
      value = "/GetVolunteerListByOrganizationRequest/{organizationName}",
      method = RequestMethod.GET)
  public @ResponseBody List<User> getVolunteerListByOrganizationRequest(
      @PathVariable("organizationName") String organizationName) {

    List<User> userList = null;
    try {
      userList = userService.getVolunteerListByOrganizationRequest(organizationName);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return userList;
  }
コード例 #19
0
ファイル: UserResource.java プロジェクト: riaval/open-note
  private Representation editSimpleData(Form form) {
    String sessionHash = form.getFirstValue("session_hash");
    String fullName = form.getFirstValue("full_name");
    String email = form.getFirstValue("email");

    try {
      mUserService.editSimpleData(sessionHash, fullName, email);

      return new JacksonRepresentation<Status>(StatusFactory.ok());
    } catch (BadAuthenticationException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientUnauthorized(e.getMessage()));
    } catch (IllegalArgumentException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientBadRequest(e.getMessage()));
    } catch (Exception e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.serverInternalError());
    }
  }
コード例 #20
0
ファイル: UserResource.java プロジェクト: riaval/open-note
  private Representation editPasswordData(Form form) {
    String sessionHash = form.getFirstValue("session_hash");
    String oldPassword = form.getFirstValue("old_password");
    String newPassword = form.getFirstValue("new_password");

    try {
      mUserService.editPassword(sessionHash, oldPassword, newPassword);

      return new JacksonRepresentation<Status>(StatusFactory.ok());
    } catch (BadAuthenticationException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientUnauthorized(e.getMessage()));
    } catch (IllegalArgumentException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientBadRequest(e.getMessage()));
    } catch (Exception e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.serverInternalError());
    }
  }
コード例 #21
0
ファイル: UserResource.java プロジェクト: riaval/open-note
  @Post
  public Representation createUser(Representation entity) {
    Form form = new Form(entity);
    try {
      String fullName = form.getFirstValue("full_name");
      String password = form.getFirstValue("password");
      String hostIp = getClientInfo().getAddress();
      String hostAgent = getClientInfo().getAgent();

      Session session = mUserService.createUser(mLogin, fullName, password, hostIp, hostAgent);

      return new JacksonRepresentation<SessionRepresentation>(new SessionRepresentation(session));
    } catch (IllegalArgumentException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientBadRequest(e.getMessage()));
    } catch (Exception e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.serverInternalError());
    }
  }
コード例 #22
0
 @RequestMapping(value = "/SuspendUserRequest/{id}", method = RequestMethod.PUT)
 public @ResponseBody SuspendUserResponse suspendUserRequest(@PathVariable("id") String id) {
   return userService.suspendUserRequest(id);
 }
コード例 #23
0
 @RequestMapping(value = "/ChangePasswordRequest", method = RequestMethod.PUT)
 public @ResponseBody ChangePasswordResponse changePasswordRequest(
     @RequestBody ChangePasswordRequest request) {
   return userService.changePasswordRequest(request);
 }
コード例 #24
0
 @RequestMapping(value = "/ActivateUserRequest/{id}", method = RequestMethod.PUT)
 public @ResponseBody ActivateUserResponse activateUserRequest(@PathVariable("id") String id) {
   return userService.activateUserRequest(id);
 }
コード例 #25
0
 @RequestMapping(value = "/UpdateUserRequest", method = RequestMethod.PUT)
 public @ResponseBody UpdateUserResponse userLoginRequest(@RequestBody User user) {
   return userService.updateUserRequest(user);
 }
コード例 #26
0
ファイル: RoleServiceImpl.java プロジェクト: sHlyoMa/SS-TC
 public Role getMyRole() {
   return getRoleById(userService.getUserByLogin().getRoleId());
 }
コード例 #27
0
 @RequestMapping(value = "/ResetPasswordRequest", method = RequestMethod.PUT)
 public @ResponseBody ResetPasswordResponse resetPasswordRequest(
     @RequestBody ResetPasswordRequest request) {
   return userService.resetPasswordRequest(request);
 }
コード例 #28
0
 @RequestMapping(value = "/VerifyResetPasswordTokenRequest/{token}", method = RequestMethod.GET)
 public @ResponseBody VerifyResetPasswordTokenResponse verifyResetPasswordTokenRequest(
     @PathVariable("token") String token) {
   return userService.verifyResetPasswordTokenRequest(token);
 }
コード例 #29
0
 @RequestMapping(value = "/DeleteUserRequest/{id}", method = RequestMethod.DELETE)
 public @ResponseBody DeleteUserResponse deleteUserRequest(@PathVariable("id") String id) {
   return userService.deleteUserRequest(id);
 }
コード例 #30
0
 @RequestMapping(value = "/CreatePendingResetPasswordRequest", method = RequestMethod.POST)
 public @ResponseBody CreatePendingResetPasswordResponse createPendingResetPasswordRequest(
     @RequestBody CreatePendingResetPasswordRequest request) {
   return userService.createPendingResetPasswordRequest(request);
 }