Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public BasicLoginController(AuthService authService) {
@GetMapping("/members/me/basic")
public ResponseEntity<MemberResponse> findMyInfo(HttpServletRequest request) {
// TODO: authorization 헤더의 Basic 값에 있는 email과 password 추출 (hint: authorizationExtractor 사용)
String email = "";
String password = "";
AuthInfo authInfo = authorizationExtractor.extract(request);
String email = authInfo.getEmail();
String password = authInfo.getPassword();

if (authService.checkInvalidLogin(email, password)) {
throw new AuthorizationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ public SessionLoginController(AuthService authService) {
@PostMapping("/login/session")
public ResponseEntity<Void> sessionLogin(HttpServletRequest request, HttpSession session) {
// TODO: HttpRequest로 받은 email과 password 추출
String email = "";
String password = "";
String email = request.getParameter(USERNAME_FIELD);
String password = request.getParameter(PASSWORD_FIELD);

if (authService.checkInvalidLogin(email, password)) {
throw new AuthorizationException();
}

// TODO: Session에 인증 정보 저장 (key: SESSION_KEY, value: email값)
session.setAttribute(SESSION_KEY, email);

return ResponseEntity.ok().build();
}
Expand All @@ -58,7 +59,7 @@ public ResponseEntity<Void> sessionLogin(HttpServletRequest request, HttpSession
@GetMapping("/members/me/session")
public ResponseEntity<MemberResponse> findMyInfo(HttpSession session) {
// TODO: Session을 통해 인증 정보 조회 (key: SESSION_KEY)
String email = "";
String email = (String) session.getAttribute(SESSION_KEY);
MemberResponse member = authService.findMember(email);
return ResponseEntity.ok().body(member);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand All @@ -35,9 +36,9 @@ public TokenLoginController(AuthService authService) {
* }
*/
@PostMapping("/login/token")
public ResponseEntity<TokenResponse> tokenLogin() {
public ResponseEntity<TokenResponse> tokenLogin(@RequestBody TokenRequest request) {
// TODO: email, password 정보를 가진 TokenRequest 값을 메서드 파라미터로 받아오기 (hint: @RequestBody)
TokenRequest tokenRequest = null;
TokenRequest tokenRequest = request;
TokenResponse tokenResponse = authService.createToken(tokenRequest);
return ResponseEntity.ok().body(tokenResponse);
}
Expand All @@ -52,7 +53,7 @@ public ResponseEntity<TokenResponse> tokenLogin() {
@GetMapping("/members/me/token")
public ResponseEntity<MemberResponse> findMyInfo(HttpServletRequest request) {
// TODO: authorization 헤더의 Bearer 값을 추출 (hint: authorizationExtractor 사용)
String token = "";
String token = authorizationExtractor.extract(request);
MemberResponse member = authService.findMemberByToken(token);
return ResponseEntity.ok().body(member);
}
Expand Down