Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-10-08 [Release Note] #179

Merged
merged 3 commits into from
Oct 8, 2024
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 @@ -5,9 +5,8 @@
import com.aliens.backend.email.controller.response.EmailResponse;
import com.aliens.backend.email.domain.EmailAuthentication;
import com.aliens.backend.email.domain.repository.EmailAuthenticationRepository;
import com.aliens.backend.member.sevice.SymmetricKeyEncoder;
import com.aliens.backend.global.response.error.EmailError;
import com.aliens.backend.global.exception.RestApiException;
import com.aliens.backend.global.response.error.EmailError;
import com.aliens.backend.member.controller.dto.event.TemporaryPasswordEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -48,7 +47,7 @@ public String sendAuthenticationEmail(final String email) {
EmailAuthentication emailEntity = new EmailAuthentication(email);
emailAuthenticationRepository.save(emailEntity);

String emailToken = SymmetricKeyEncoder.encrypt(email);
String emailToken = email;
emailSender.sendAuthenticationEmail(email, emailToken);

return EmailResponse.EMAIL_SEND_SUCCESS.getMessage();
Expand All @@ -68,7 +67,7 @@ private void deleteExistsEmail(final String email) {

@Transactional
public String authenticateEmail(final String token) {
String email = SymmetricKeyEncoder.decrypt(token);
String email = token;
EmailAuthentication emailEntity = getEmailAuthenticationByEmail(email);
emailEntity.authenticate();
return EmailResponse.EMAIL_AUTHENTICATION_SUCCESS.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ void sendAuthenticationEmailTest() throws Exception {
void authenticateEmailTest() throws Exception {
//Given
emailAuthenticationRepository.save(emailEntity);
String token = symmetricKeyEncoder.encrypt(givenEmail);

//When
String result = emailService.authenticateEmail(token);
String result = emailService.authenticateEmail(givenEmail);

//Then
Assertions.assertEquals(EmailResponse.EMAIL_AUTHENTICATION_SUCCESS.getMessage(), result);
Expand Down
Loading