PAN-54 Created user registration page.

This commit is contained in:
BrittanyBi
2019-03-24 15:37:39 -06:00
parent de5a69d619
commit 0fc825e11b
4 changed files with 123 additions and 0 deletions
@@ -0,0 +1,40 @@
package edu.msudenver.tsp.website.controller;
import edu.msudenver.tsp.website.forms.UserCreationForm;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Slf4j
@Controller
@AllArgsConstructor
@RequestMapping("/createuser")
public class UserCreationController {
@GetMapping({"/",""})
public ModelAndView createUserPage() {
LOG.info("Received request to display the user creation page: returning model with name 'User'");
return new ModelAndView("User");
}
@PostMapping({"/",""})
public String registerUser(@Validated final UserCreationForm userCreationForm, final Model model) {
model.addAttribute("userID", userCreationForm.getUserID());
model.addAttribute("username", userCreationForm.getUsername());
model.addAttribute("password", userCreationForm.getPassword());
model.addAttribute("emailAddress", userCreationForm.getEmailAddress());
model.addAttribute("firstName", userCreationForm.getFirstName());
model.addAttribute("lastName", userCreationForm.getLastName());
model.addAttribute("referrer", userCreationForm.getReferrer());
model.addAttribute("TnCAgreement", userCreationForm.isAgreedToTerms());
LOG.info("Saving user {}...", userCreationForm);
return "success";
}
}
@@ -0,0 +1,18 @@
package edu.msudenver.tsp.website.forms;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserCreationForm {
private int userID;
private String username;
private String password;
private String confirmPassword;
private String emailAddress;
private String firstName;
private String lastName;
private String referrer; // optional
private boolean agreedToTerms;
}