Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package pl.edu.pb.mz.controller;
  2.  
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.web.bind.annotation.ModelAttribute;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11.  
  12. import pl.edu.pb.mz.service.PersonService;
  13. import pl.edu.pb.mz.service.Validator;
  14.  
  15. @Controller
  16. @RequestMapping("/login")
  17. public class LoginController extends AbstractController{
  18. private final Logger logger = LoggerFactory.getLogger(LoginController.class);
  19. @Autowired
  20. PersonService personService;
  21.  
  22. @Autowired
  23. Validator validator;
  24.  
  25. @ResponseBody
  26. @RequestMapping(method = RequestMethod.POST)
  27. public String login(@ModelAttribute("username") String userName, @ModelAttribute("password") String password) {
  28. logger.debug("username: {}, pass: {}", userName, password);
  29. if (validator.checkUserName(userName) && validator.checkPassword(password)
  30. && personService.validatePassword(userName, password)) {
  31. logger.debug("password valid");
  32. return toJsonResponse("success");
  33. }
  34. logger.debug("password invalid");
  35. return toJsonResponse("error");
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement