Ejemplo n.º 1
0
 private void sendConfirmationMail(String username, String email) {
   String subject = "Verify";
   String token = userDao.getRegisterToken(username);
   String link = "http://localhost:8000/#/ShopOnline/token/" + token + "/registration/" + username;
   SendMail send = new SendMail(username, email, "RegisterContent.html", subject, link);
   send.run();
 }
Ejemplo n.º 2
0
  private void sendGetPasswordMail(String username, String email) {
    String subject = "Forgot";
    String token = userDao.getForgotPasswordToken(username);
    String link =
        "http://localhost:8000/#/ShopOnline/token/" + token + "/forgotpassword/" + username;

    SendMail send = new SendMail(username, email, "ResetPassContent.html", subject, link);
    send.run();
  }
Ejemplo n.º 3
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.º 4
0
 @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);
 }
Ejemplo n.º 5
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.º 6
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);
 }
Ejemplo n.º 7
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.º 8
0
 @RequestMapping(value = "/{username}", method = RequestMethod.GET)
 @ResponseBody
 public ResponseEntity<User> GetUser(@PathVariable("username") String username) {
   User user = userDao.getUserByUserName(username);
   return new ResponseEntity<User>(user, HttpStatus.OK);
 }