示例#1
0
  @RequestMapping(value = "/submitsignup", method = RequestMethod.POST)
  public View submitSignup(@Valid SignupForm signupForm) {

    User newUser = new User();
    newUser.setUsername(signupForm.getUsername());
    newUser.setPassword(signupForm.getPassword());
    newUser.setRole(permissions.getStartingRole());

    userRepository.save(newUser);

    forumSession.setCurrentUser(newUser);

    return new RedirectView("/", true);
  }
示例#2
0
  public User getUser(LoginForm loginForm) {

    User user = userRepository.findByUsername(loginForm.getUsername());
    user.setRole(permissions.getRole(user.getRoleId()));

    if (user != null) {
      if (!user.getPassword().equals(loginForm.getPassword())) {
        user = SessionData.UNREGISTERED_USER;
      }
    } else if (!loginForm.getUsername().equals("root")) {
      user = SessionData.UNREGISTERED_USER;
    } else if (loginForm.getPassword().equals(forumProperties.rootPassword)) {
      user = SessionData.ROOT_USER;
    }

    return user;
  }