Ejemplo n.º 1
0
 @RequestMapping(
     value = "/new",
     method = RequestMethod.POST,
     consumes = {"application/json"})
 @ResponseBody
 public ResponseEntity<User> AddUser(@RequestBody User user) {
   User newUser =
       userDao.createNewUser(user.getUserName(), user.getUserEmail(), user.getUserPassword(), 3);
   if (newUser != null) {
     sendConfirmationMail(newUser.getUserName(), newUser.getUserEmail());
     return new ResponseEntity<User>(newUser, HttpStatus.OK);
   } else return new ResponseEntity<User>(HttpStatus.CONFLICT);
 }
Ejemplo n.º 2
0
 @RequestMapping(
     value = "/login",
     method = RequestMethod.POST,
     consumes = {"application/json"})
 @ResponseBody
 public ResponseEntity<User> LoginUser(@RequestBody User user) {
   User newUser = userDao.login(user.getUserName(), user.getUserPassword());
   if (newUser == null) return new ResponseEntity<User>(newUser, HttpStatus.BAD_REQUEST);
   return new ResponseEntity<User>(newUser, HttpStatus.OK);
 }
Ejemplo n.º 3
0
 @RequestMapping(
     value = "/forgotpassword",
     method = RequestMethod.POST,
     consumes = {"application/json"})
 @ResponseBody
 public ResponseEntity<User> ForgotPassword(@RequestBody User userEmail) {
   User user = userDao.createToken(userEmail.getUserEmail());
   if (user == null) return new ResponseEntity<User>(HttpStatus.NOT_FOUND);
   sendGetPasswordMail(user.getUserName(), user.getUserEmail());
   return new ResponseEntity<User>(user, HttpStatus.OK);
 }
Ejemplo n.º 4
0
 @RequestMapping(
     value = "/update/token/{token}",
     method = RequestMethod.POST,
     consumes = {"application/json"})
 @ResponseBody
 public ResponseEntity<User> UpdateUserPassword(
     @RequestBody User user, @PathVariable("token") String token) {
   User reUser = userDao.updateUserPassword(user.getUserName(), user.getUserPassword(), token);
   if (reUser == null) return new ResponseEntity<User>(reUser, HttpStatus.NOT_FOUND);
   return new ResponseEntity<User>(reUser, HttpStatus.OK);
 }