@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); }
@RequestMapping( value = "/update/info/{username}", method = RequestMethod.POST, consumes = {"application/json"}) @ResponseBody public ResponseEntity<User> UpdateInfo( @RequestBody User user, @PathVariable("username") String username) { User newUser = userDao.updateInfo(user.getUserEmail(), user.getUserPhoneNumber()); if (newUser == null) return new ResponseEntity<User>(newUser, HttpStatus.NOT_FOUND); return new ResponseEntity<User>(newUser, HttpStatus.OK); }
@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); }
@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); }
@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); }