Exemplo n.º 1
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();
  }
Exemplo n.º 2
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";
   }
 }