-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathAccountController.java
34 lines (26 loc) · 1.13 KB
/
AccountController.java
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
package nextstep.app.ui;
import jakarta.servlet.http.HttpServletRequest;
import nextstep.security.web.csrf.CsrfToken;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.bind.annotation.RequestParam;
@Controller
@RequestMapping("/account")
public class AccountController {
@GetMapping
public String getAccountPage(HttpServletRequest request, Model model) {
model.addAttribute("username", "username");
model.addAttribute("email", "[email protected]");
CsrfToken csrfToken = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
model.addAttribute("csrfToken", csrfToken);
return "account";
}
@PostMapping("/update")
public String updateAccount(@RequestParam("username") String username, @RequestParam("email") String email) {
// 사용자 정보를 업데이트하는 로직
return "redirect:/account";
}
}