Skip to content

Commit

Permalink
Merge pull request #83 from gfa-cc-after/SCRUM-75
Browse files Browse the repository at this point in the history
SCRUM-75: Add the email service call when someone registers
  • Loading branch information
markkovari authored Aug 29, 2024
2 parents 621316a + 29501bd commit 22e8d15
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import org.springframework.context.annotation.Configuration;

/**
* This configuration is to setup the email sending services.
* Configuration class for managing email-related settings.
* <p>
* This class is used to load email-related properties from the application's configuration files,
* such as the base URL used for email verification links.
* It leverages Spring's {@link Configuration}
* and {@link Value} annotations to inject configuration properties into the class.
* </p>
*/
@Configuration
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Collection;
import java.util.List;
import java.util.UUID;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.UUID;

/**
* Service to handle emails.
* An interface for a service that handles sending emails.
*/
public interface EmailService {
EmailSentDto sendRegistrationEmail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

/**
* EmailServiceImplementation to handle emails.
* Implementation of the {@link EmailService} interface for sending registration emails.
* This service uses Spring's {@link JavaMailSender} to create and send emails
* with a registration verification link.
*/
@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.greenfoxacademy.backend.services.mail.EmailService;
import jakarta.transaction.Transactional;
import java.util.UUID;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
Expand Down Expand Up @@ -80,7 +79,7 @@ public ProfileUpdateResponseDto profileUpdate(
.orElseThrow(() -> new UsernameNotFoundException("User not found"));
if (
userRepository.existsByEmail(profileUpdateRequestDto.email())
&& !Objects.equals(email, profileUpdateRequestDto.email())
&& !email.equals(profileUpdateRequestDto.email())
) {
throw new CannotUpdateUserException("Email is already taken!");
}
Expand Down

0 comments on commit 22e8d15

Please sign in to comment.