Skip to content

Commit

Permalink
#33 - Feat: 로그인 요청시, 입력 데이터(username, password) 유효성 검증
Browse files Browse the repository at this point in the history
  • Loading branch information
ahah525 committed Nov 8, 2022
1 parent 058a935 commit a06a89d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class MemberApiController {

@PostMapping("/login")
public ResponseEntity<String> login(@RequestBody LoginDto loginDto) {
// 입력 데이터 유효성 검증
if(loginDto.isNotValid()) {
return new ResponseEntity<>(null, null, HttpStatus.BAD_REQUEST);
}

// 헤더(Authentication) 에 JWT 토큰 & 바디에 username, password
HttpHeaders headers = new HttpHeaders();
headers.set("Authentication", "JWT Token");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public class LoginDto {
private String username;
@NotBlank(message = "password 을(를) 입력해주세요.")
private String password;

public boolean isNotValid() {
return username == null || password == null || username.trim().length() == 0 || password.trim().length() == 0;
}
}

0 comments on commit a06a89d

Please sign in to comment.