Skip to content
Merged
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
@@ -0,0 +1,10 @@
package org.fontory.fontorybe.authentication.domain.exception;

import org.fontory.fontorybe.common.domain.SkipDiscordNotification;

@SkipDiscordNotification
public class AuthenticationRequiredException extends RuntimeException {
public AuthenticationRequiredException() {
super("Authentication required");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.MalformedJwtException;
import lombok.RequiredArgsConstructor;
import org.fontory.fontorybe.authentication.domain.exception.AuthenticationRequiredException;
import org.fontory.fontorybe.authentication.domain.exception.InvalidRefreshTokenException;
import org.fontory.fontorybe.authentication.domain.exception.TokenNotFoundException;
import org.fontory.fontorybe.bookmark.domain.exception.BookmarkAlreadyException;
Expand Down Expand Up @@ -169,4 +170,10 @@ public BaseErrorResponse fileNotFoundException(FileNotFoundException e) {
public BaseErrorResponse containsBadWordException(Exception e) {
return new BaseErrorResponse(e.getMessage());
}

@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(AuthenticationRequiredException.class)
public BaseErrorResponse authenticationRequiredException(AuthenticationRequiredException e) {
return new BaseErrorResponse(e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.fontory.fontorybe.authentication.adapter.inbound.annotation.Login;
import org.fontory.fontorybe.authentication.application.AuthService;
import org.fontory.fontorybe.authentication.domain.UserPrincipal;
import org.fontory.fontorybe.authentication.domain.exception.AuthenticationRequiredException;
import org.fontory.fontorybe.file.application.port.CloudStorageService;
import org.fontory.fontorybe.file.application.port.FileService;
import org.fontory.fontorybe.file.domain.FileUploadResult;
Expand All @@ -20,6 +21,7 @@
import org.fontory.fontorybe.member.controller.port.MemberLookupService;
import org.fontory.fontorybe.member.controller.port.MemberUpdateService;
import org.fontory.fontorybe.member.domain.Member;
import org.fontory.fontorybe.member.infrastructure.entity.MemberStatus;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -54,6 +56,9 @@ public ResponseEntity<MyProfileResponse> getMyProfile(
log.info("Request received: getMyInfo member ID: {}", requestMemberId);

Member lookupMember = memberLookupService.getOrThrowById(requestMemberId);
if (lookupMember.getStatus().equals(MemberStatus.ONBOARDING)) {
throw new AuthenticationRequiredException();
}
String fileUrl = cloudStorageService.getProfileImageUrl(lookupMember.getProfileImageKey());
log.info("ProfileImageUrl generated : {}", fileUrl);

Expand Down
Loading