-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
1,520 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/gdschongik/gdsc/domain/auth/api/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.gdschongik.gdsc.domain.auth.api; | ||
|
||
import static com.gdschongik.gdsc.global.common.constant.JwtConstant.Constants.*; | ||
|
||
import com.gdschongik.gdsc.global.util.CookieUtil; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.Cookie; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.CookieValue; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "Auth", description = "인증 API입니다.") | ||
@RestController | ||
@RequestMapping("/auth") | ||
@RequiredArgsConstructor | ||
public class AuthController { | ||
|
||
private final CookieUtil cookieUtil; | ||
|
||
@Operation(summary = "로그아웃", description = "현재 엑세스 토큰 및 리프레시 토큰 쿠키를 만료시킵니다.") | ||
@GetMapping("/logout") | ||
public ResponseEntity<Void> logout( | ||
@CookieValue(ACCESS_TOKEN_COOKIE_NAME) Cookie accessToken, | ||
@CookieValue(REFRESH_TOKEN_COOKIE_NAME) Cookie refreshToken, | ||
HttpServletResponse response) { | ||
cookieUtil.deleteCookie(accessToken, response); | ||
cookieUtil.deleteCookie(refreshToken, response); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/com/gdschongik/gdsc/domain/auth/dto/AccessTokenDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.gdschongik.gdsc.domain.auth.dto; | ||
|
||
import com.gdschongik.gdsc.domain.member.domain.MemberRole; | ||
import com.gdschongik.gdsc.global.security.MemberAuthInfo; | ||
|
||
public record AccessTokenDto(Long memberId, MemberRole memberRole, String tokenValue) {} | ||
public record AccessTokenDto(MemberAuthInfo authInfo, String tokenValue) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...om/gdschongik/gdsc/domain/discord/application/handler/MemberDiscordRoleRevokeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.gdschongik.gdsc.domain.discord.application.handler; | ||
|
||
import static com.gdschongik.gdsc.global.common.constant.DiscordConstant.*; | ||
|
||
import com.gdschongik.gdsc.domain.member.domain.MemberDemotedToAssociateEvent; | ||
import com.gdschongik.gdsc.global.util.DiscordUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.dv8tion.jda.api.entities.Guild; | ||
import net.dv8tion.jda.api.entities.Member; | ||
import net.dv8tion.jda.api.entities.Role; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class MemberDiscordRoleRevokeHandler implements SpringEventHandler { | ||
|
||
private final DiscordUtil discordUtil; | ||
|
||
@Override | ||
public void delegate(Object context) { | ||
MemberDemotedToAssociateEvent event = (MemberDemotedToAssociateEvent) context; | ||
Guild guild = discordUtil.getCurrentGuild(); | ||
Member member = discordUtil.getMemberById(event.discordId()); | ||
Role role = discordUtil.findRoleByName(MEMBER_ROLE_NAME); | ||
|
||
guild.removeRoleFromMember(member, role).queue(); | ||
|
||
log.info( | ||
"[MemberDiscordRoleRevokeHandler] 디스코드 서버 정회원 역할 제거 완료: memberId={}, discordId={}", | ||
event.memberId(), | ||
event.discordId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ongik/gdsc/domain/discord/application/listener/MemberDemotedToAssociateEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.gdschongik.gdsc.domain.discord.application.listener; | ||
|
||
import com.gdschongik.gdsc.domain.discord.application.handler.MemberDiscordRoleRevokeHandler; | ||
import com.gdschongik.gdsc.domain.member.domain.MemberDemotedToAssociateEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class MemberDemotedToAssociateEventListener { | ||
|
||
private final MemberDiscordRoleRevokeHandler memberDiscordRoleRevokeHandler; | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
public void demoteMemberToAssociate(MemberDemotedToAssociateEvent event) { | ||
log.info( | ||
"[MemberDemotedToAssociateEventListener] 회원 준회원 강등 이벤트 수신: memberId={}, discordId={}", | ||
event.memberId(), | ||
event.discordId()); | ||
memberDiscordRoleRevokeHandler.delegate(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.