-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathUserController.java
More file actions
54 lines (40 loc) · 1.31 KB
/
UserController.java
File metadata and controls
54 lines (40 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.launchcode.spaday.controllers;
import org.launchcode.spaday.models.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@Controller
@RequestMapping("user")
public class UserController {
@GetMapping("/add")
public String displayAddUserForm(Model model) {
model.addAttribute(new User());
return "user/add";
}
@PostMapping
public String processAddUserForm(Model model, @ModelAttribute @Valid User user, Errors errors, String verify) {
if (errors.hasErrors() || (user.getPassword().equals(verify))){
model.addAttribute("ERROR");
return "user/add";
}
return "user/index";
/*
if (user.getPassword().equals(verify)) {
return "user/index";
}
/*
model.addAttribute("user", user);
model.addAttribute("verify", verify);
model.addAttribute("username", user.getUsername());
model.addAttribute("email", user.getEmail());
model.addAttribute(new User());
return "/user";
*/
// else {
// model.addAttribute("error", "Passwords do not match");
// return "add";
// }
}
}