Skip to content

Commit

Permalink
Merge pull request #214 from JNU-econovation/feature/BE-79
Browse files Browse the repository at this point in the history
[BE-79] feat : 로그인 실패 시 쿠키 삭제
  • Loading branch information
LJH098 authored Mar 9, 2024
2 parents 1b0626e + 5a0b024 commit 767e611
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 10 deletions.
Binary file removed .github/.DS_Store
Binary file not shown.
Binary file removed .gradle/7.6.1/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/7.6.1/checksums/md5-checksums.bin
Binary file not shown.
Binary file removed .gradle/7.6.1/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Empty file.
Binary file removed .gradle/7.6.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file removed .gradle/7.6.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/7.6.1/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/7.6.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/7.6.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/7.6.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file removed .gradle/7.6.1/gc.properties
Empty file.
Binary file removed .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 0 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties

This file was deleted.

Binary file removed .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file removed .gradle/file-system.probe
Binary file not shown.
Empty file removed .gradle/vcs-1/gc.properties
Empty file.
51 changes: 51 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Recruit-Domain/HELP.md
.gradle
.gradle/**
.server/.gradle/**
.server/.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.DS_Store
./**/.DS_Store
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
server/.env
.env
.env.*

*.xlsx
/Recruit-Domain/src/main/generated/
Recruit-Domain/src/main/generated/**/*.java

# Ignore Gradle build output directory
build
Binary file not shown.
2 changes: 0 additions & 2 deletions server/.gradle/buildOutputCleanup/cache.properties

This file was deleted.

Binary file removed server/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file removed server/.gradle/file-system.probe
Binary file not shown.
Empty file removed server/.gradle/vcs-1/gc.properties
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ public ResponseEntity<TokenResponse> issueToken() {
@PostMapping("/login")
public ResponseEntity<TokenResponse> login(
@RequestBody LoginRequestDto loginRequestDto, HttpServletResponse response) {
TokenResponse tokenResponse = userLoginUseCase.execute(loginRequestDto);
TokenResponse tokenResponse = userLoginUseCase.execute(loginRequestDto, response);
response.addHeader(
"Set-Cookie",
SecurityUtils.setCookie("refreshToken", tokenResponse.getRefreshToken())
SecurityUtils.logoutCookie("refreshToken", tokenResponse.getRefreshToken())
.toString());
response.addHeader(
"Set-Cookie",
SecurityUtils.setCookie("accessToken", tokenResponse.getAccessToken()).toString());
SecurityUtils.logoutCookie("accessToken", tokenResponse.getAccessToken())
.toString());
return new ResponseEntity<>(tokenResponse, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.econovation.recruitdomain.domains.interviewer.exception.InterviewerNotMatchException;
import com.econovation.recruitdomain.out.InterviewerLoadPort;
import com.econovation.recruitdomain.out.InterviewerRecordPort;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
Expand All @@ -28,11 +29,23 @@ public class UserService implements UserRegisterUseCase, UserLoginUseCase {

@Override
@Transactional
public TokenResponse execute(LoginRequestDto loginRequestDto) {
public TokenResponse execute(LoginRequestDto loginRequestDto, HttpServletResponse response) {
Interviewer account =
interviewerLoadPort.loadInterviewerByEmail(loginRequestDto.getEmail());
checkPassword(loginRequestDto.getPassword(), account.getPassword());
return jwtTokenProvider.createToken(account.getId(), account.getRole().name());
TokenResponse tokenResponse =
jwtTokenProvider.createToken(account.getId(), account.getRole().name());
response.addHeader(
"Set-Cookie",
com.econovation.recruit.utils.SecurityUtils.setCookie(
"refreshToken", tokenResponse.getRefreshToken())
.toString());
response.addHeader(
"Set-Cookie",
com.econovation.recruit.utils.SecurityUtils.setCookie(
"accessToken", tokenResponse.getAccessToken())
.toString());
return tokenResponse;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.econovation.recruitcommon.annotation.UseCase;
import com.econovation.recruitcommon.dto.TokenResponse;
import com.econovation.recruitdomain.domains.dto.LoginRequestDto;
import javax.servlet.http.HttpServletResponse;

@UseCase
public interface UserLoginUseCase {
TokenResponse execute(LoginRequestDto loginRequestDto);
TokenResponse execute(LoginRequestDto loginRequestDto, HttpServletResponse response);

TokenResponse refresh(String refreshToken);
}

0 comments on commit 767e611

Please sign in to comment.