PAN-54 Created user registration page.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user