a6468920
sangkiham
Spring Boot Board...
|
1
2
|
package com.daeucna.board.security.controller;
|
d434ebaa
sangkiham
회원가입화면추가
|
3
4
|
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
|
a6468920
sangkiham
Spring Boot Board...
|
5
6
|
import javax.servlet.http.HttpSession;
|
d434ebaa
sangkiham
회원가입화면추가
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
a6468920
sangkiham
Spring Boot Board...
|
8
9
10
|
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
|
a6468920
sangkiham
Spring Boot Board...
|
11
12
13
|
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
|
d434ebaa
sangkiham
회원가입화면추가
|
14
|
import org.springframework.web.bind.annotation.PostMapping;
|
a6468920
sangkiham
Spring Boot Board...
|
15
16
17
18
|
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.daeucna.board.security.domain.UserDto;
|
d434ebaa
sangkiham
회원가입화면추가
|
19
20
|
import com.daeucna.board.security.domain.UserForm;
import com.daeucna.board.security.service.LoginService;
|
a6468920
sangkiham
Spring Boot Board...
|
21
22
23
24
25
26
27
28
|
import lombok.extern.slf4j.Slf4j;
@Controller
@RequestMapping("/")
@Slf4j
public class LoginController {
|
d434ebaa
sangkiham
회원가입화면추가
|
29
30
|
@Autowired
private LoginService loginService;
|
a6468920
sangkiham
Spring Boot Board...
|
31
|
|
d434ebaa
sangkiham
회원가입화면추가
|
32
33
34
35
36
37
|
@GetMapping("/login")
public String getlogin(Model model) {
log.info("로그인 Page");
return "page/login/login";
}
|
a6468920
sangkiham
Spring Boot Board...
|
38
39
40
41
42
43
44
45
46
47
48
49
|
@GetMapping("/info")
@ResponseBody
public String getCurrentUserInfo(HttpSession httpSession) {
try {
Authentication authentication = (Authentication) httpSession.getAttribute("authentication");
UserDto userDto = (UserDto) authentication.getPrincipal();
log.info("user : " + userDto );
return userDto.getUsername() + "은 로그인중입니다";
} catch (Exception e) {
return "먼저 로그인을 하세요";
}
}
|
d434ebaa
sangkiham
회원가입화면추가
|
50
51
52
53
54
55
56
|
@GetMapping("/join")
public String getJoin(Model model) {
log.info("회원가입 Page");
return "page/login/join";
}
|
cb01f7b1
sangkiham
.
|
57
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
d434ebaa
sangkiham
회원가입화면추가
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
@PostMapping("/join_proc")
@ResponseBody
public ResponseEntity procJoin(HttpServletRequest request, HttpServletResponse response, UserForm userForm) {
HttpStatus httpStatus = null;
UserForm resultUserForm = null;
try {
resultUserForm = loginService.procJoin(userForm);
httpStatus = HttpStatus.OK;
} catch (Exception e) {
httpStatus = HttpStatus.BAD_REQUEST;
}
return new ResponseEntity(resultUserForm, httpStatus);
}
|
a6468920
sangkiham
Spring Boot Board...
|
72
73
|
}
|