Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.edu.pb.mz.controller;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import pl.edu.pb.mz.service.PersonService;
- import pl.edu.pb.mz.service.Validator;
- @Controller
- @RequestMapping("/login")
- public class LoginController extends AbstractController{
- private final Logger logger = LoggerFactory.getLogger(LoginController.class);
- @Autowired
- PersonService personService;
- @Autowired
- Validator validator;
- @ResponseBody
- @RequestMapping(method = RequestMethod.POST)
- public String login(@ModelAttribute("username") String userName, @ModelAttribute("password") String password) {
- logger.debug("username: {}, pass: {}", userName, password);
- if (validator.checkUserName(userName) && validator.checkPassword(password)
- && personService.validatePassword(userName, password)) {
- logger.debug("password valid");
- return toJsonResponse("success");
- }
- logger.debug("password invalid");
- return toJsonResponse("error");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement