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
Expand Up @@ -71,7 +71,7 @@ public boolean isTokenExpired(String token) {
return claims.getExpiration().before(new Date());
} catch (Exception e) {
log.error("Token is expired: {}", e.getMessage());
throw new JwtException(AuthErrorCode.EMPTY_ACCESS_KEY);
throw new JwtException(AuthErrorCode.EXPIRED_TOKEN);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean isTokenExpired(String token) {
return claims.getExpiration().before(new Date());
} catch (Exception e) {
log.error("Token is expired: {}", e.getMessage());
throw new JwtException(AuthErrorCode.EMPTY_ACCESS_KEY);
throw new JwtException(AuthErrorCode.EXPIRED_TOKEN);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean isTokenExpired(String token) {
return claims.getExpiration().before(new Date());
} catch (Exception e) {
log.error("Token is expired: {}", e.getMessage());
throw new JwtException(AuthErrorCode.EMPTY_ACCESS_KEY);
throw new JwtException(AuthErrorCode.EXPIRED_TOKEN);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package clap.server.application.service.admin;

import clap.server.application.port.outbound.email.SendEmailPort;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;
@Slf4j
@Service
@RequiredArgsConstructor
public class SendInvitationEmailService {
private final SendEmailPort sendEmailPort;

@Async("emailExecutor")
public void sendInvitationEmail(String memberEmail, String receiverName, String initialPassword, String userNickname) {
CompletableFuture.runAsync(() -> {
try {
sendEmailPort.sendInvitationEmail(memberEmail, receiverName, initialPassword, userNickname);
} catch (Exception e) {
log.error("Failed to send new password email to: {}", memberEmail, e);
}
}).exceptionally(ex -> {
log.error("Unexpected error occurred while sending new password email", ex);
return null;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import clap.server.application.port.inbound.admin.SendInvitationUsecase;
import clap.server.application.port.outbound.member.CommandMemberPort;
import clap.server.application.port.outbound.member.LoadMemberPort;
import clap.server.application.port.outbound.email.SendEmailPort;
import clap.server.common.annotation.architecture.ApplicationService;
import clap.server.common.utils.InitialPasswordGenerator;
import clap.server.domain.model.member.Member;
Expand All @@ -19,7 +18,7 @@
public class SendInvitationService implements SendInvitationUsecase {
private final LoadMemberPort loadMemberPort;
private final CommandMemberPort commandMemberPort;
private final SendEmailPort sendEmailPort;
private final SendInvitationEmailService sendInvitationEmailService;
private final InitialPasswordGenerator passwordGenerator;
private final PasswordEncoder passwordEncoder;

Expand All @@ -37,7 +36,7 @@ public void sendInvitation(SendInvitationRequest request) {

member.changeToApproveRequested();

sendEmailPort.sendInvitationEmail(
sendInvitationEmailService.sendInvitationEmail(
member.getMemberInfo().getEmail(),
member.getMemberInfo().getName(),
initialPassword,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import clap.server.application.port.inbound.member.ResetInitialPasswordUsecase;
import clap.server.application.port.inbound.member.ResetPasswordUsecase;
import clap.server.application.port.inbound.member.SendNewPasswordUsecase;
import clap.server.application.port.outbound.email.SendEmailPort;
import clap.server.application.port.outbound.member.CommandMemberPort;
import clap.server.application.port.outbound.member.LoadMemberPort;
import clap.server.common.annotation.architecture.ApplicationService;
Expand All @@ -28,7 +27,7 @@ class ResetPasswordService implements ResetPasswordUsecase, ResetInitialPassword
private final CommandMemberPort commandMemberPort;
private final LoadMemberPort loadMemberPort;
private final InitialPasswordGenerator initialPasswordGenerator;
private final SendEmailPort sendEmailPort;
private final SendPasswordEmailService sendPasswordEmailService;

@Override
public void resetPassword(Long memberId, String inputPassword) {
Expand All @@ -52,7 +51,7 @@ public void sendInitialPassword(SendInitialPasswordRequest request) {
() -> new ApplicationException(MemberErrorCode.MEMBER_NOT_FOUND));

String newPassword = initialPasswordGenerator.generateRandomPassword();
sendEmailPort.sendNewPasswordEmail(request.email(), request.name(), newPassword);
sendPasswordEmailService.sendNewPasswordEmail(request.email(), request.name(), newPassword);
String encodedPassword = passwordEncoder.encode(newPassword);
member.resetPassword(encodedPassword);
commandMemberPort.save(member);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package clap.server.application.service.member;

import clap.server.application.port.outbound.email.SendEmailPort;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;

@Slf4j
@Service
@RequiredArgsConstructor
public class SendPasswordEmailService {
private final SendEmailPort sendEmailPort;

@Async("emailExecutor")
public void sendNewPasswordEmail(String email, String name, String newPassword) {
CompletableFuture.runAsync(() -> {
try {
sendEmailPort.sendNewPasswordEmail(email, name, newPassword);
} catch (Exception e) {
log.error("Failed to send new password email to: {}", email, e);
}
}).exceptionally(ex -> {
log.error("Unexpected error occurred while sending new password email", ex);
return null;
});
}
}
2 changes: 1 addition & 1 deletion src/main/java/clap/server/domain/model/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void approveTask(Member reviewer, Member processor, LocalDateTime dueDate
}

private static String toTaskCode(Category category) {
return category.getMainCategory().getCode() + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmm"));
return category.getMainCategory().getCode() + category.getCode() + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmm"));
}

public void updateProcessorOrder(long newProcessorOrder) {
Expand Down