示例#1
0
  @RequestMapping(value = "/getemail") // add post when deployed
  public @ResponseBody String getEmail(HttpSession session) throws JSONException {
    String type = (String) session.getAttribute("type");
    if (type != null) {
      int id = (Integer) session.getAttribute("id");
      return userService.getUser(id, type).email;
    }

    return "";
  }
示例#2
0
  @RequestMapping(value = "/change/passwd", method = RequestMethod.POST) // add post when deployed
  public String changePasswd(HttpSession session, @RequestParam(value = "passwd") String passwd)
      throws JSONException {

    String type = (String) session.getAttribute("type");
    if (type != null) {
      int id = (Integer) session.getAttribute("id");
      userService.updatePassword(id, passwd, type);
    }
    return "redirect:/dash";
  }
示例#3
0
 @RequestMapping(value = "/dash")
 public String dash(HttpSession session, ModelMap model) throws JSONException {
   String type = (String) session.getAttribute("type");
   if (type == null) {
     return "timeout";
   }
   Integer id = (Integer) session.getAttribute("id");
   User user = userService.getUser(id, type);
   model.addAttribute("email", user.email);
   if (type.equals("company")) {
     return "forward:/empd";
   } else {
     return "forward:/apyd";
   }
 }
示例#4
0
  @RequestMapping(value = "/change/email", method = RequestMethod.POST) // add post when deployed
  public String changeEmail(
      HttpSession session, @RequestParam(value = "email") String email, ModelMap model)
      throws JSONException {
    String type = (String) session.getAttribute("type");
    if (type != null) {
      int id = (Integer) session.getAttribute("id");
      if (!userService.updateEmail(id, email, type)) {
        model.addAttribute("err", "Email already used");
      }
      ;
    }

    return "redirect:/dash";
  }
示例#5
0
 @RequestMapping(value = "/reg/{type}", method = RequestMethod.POST)
 public @ResponseBody String register(
     @RequestParam(value = "f_name") String fName,
     @RequestParam(value = "l_name") String lName,
     @RequestParam(value = "com_name", required = false, defaultValue = "") String comName,
     @RequestParam(value = "email") String email,
     @RequestParam(value = "pass") String pass,
     @PathVariable("type") String type)
     throws JSONException {
   User user = new User();
   user.comname = comName;
   user.email = email;
   user.fname = fName;
   user.lname = lName;
   user.type = type;
   if (userService.register(user, pass)) {
     return "success";
   } else {
     return "fail";
   }
 }
示例#6
0
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public @ResponseBody String login(
      @RequestParam(value = "email", required = false) String email,
      @RequestParam(value = "pass", required = false) String passwd,
      HttpSession session)
      throws JSONException {
    User user = new User();
    user.email = email;
    user = userService.login(user, passwd);
    JSONObject res = new JSONObject();
    if (user == null) {

      res.put("state", "mismatch");
      return res.toString();
    }
    res.put("state", "success");
    session.setAttribute("id", user.Id);
    session.setAttribute("type", user.type);
    res.put("id", user.Id);
    res.put("type", user.type);
    return res.toString();
  }