Skip to content
Merged
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
@@ -1,6 +1,5 @@
package life.mosu.mosuserver.global.initializer;

import jakarta.annotation.PostConstruct;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -9,6 +8,11 @@
import java.util.Random;
import java.util.Set;
import java.util.UUID;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

import jakarta.annotation.PostConstruct;
import life.mosu.mosuserver.domain.application.ApplicationJpaEntity;
import life.mosu.mosuserver.domain.application.ApplicationJpaRepository;
import life.mosu.mosuserver.domain.application.Subject;
Expand Down Expand Up @@ -51,8 +55,6 @@
import life.mosu.mosuserver.domain.user.UserRole;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Slf4j
@Component
Expand Down Expand Up @@ -106,7 +108,7 @@ private List<UserJpaEntity> createUsersAndProfiles(Random random) {
.password(passwordEncoder.encode("Password!" + i))
.gender(i % 2 == 0 ? Gender.MALE : Gender.FEMALE)
.name("모수학생" + i)
.phoneNumber("010-5048-6201")
.phoneNumber("010-1234-5678")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Thank you for removing the hardcoded personal information. This is an important security improvement.

The new dummy phone number "010-1234-5678" is now a 'magic string'. According to Java best practices, it's better to avoid magic strings, especially when they are duplicated (as seen here and on line 148).

To improve maintainability, I recommend defining this value as a private static final constant at the class level. This ensures consistency and makes future changes easier.

Example:
You could add this field to your class:

private static final String DUMMY_PHONE_NUMBER = "010-1234-5678";

And then use the constant DUMMY_PHONE_NUMBER in both places.

.birth(LocalDate.of(2005 + i % 3, (i % 12) + 1, (i % 28) + 1))
.userRole(i == 1 ? UserRole.ROLE_ADMIN : UserRole.ROLE_USER)
.agreedToTermsOfService(true)
Expand Down Expand Up @@ -143,7 +145,7 @@ private void createAdditionalUsers() {
.password(passwordEncoder.encode("Password!" + i))
.gender(i % 2 == 0 ? Gender.MALE : Gender.FEMALE)
.name("홍길동")
.phoneNumber("010-5048-6201")
.phoneNumber("010-1234-5678")
.birth(LocalDate.of(2005 + i % 3, (i % 12) + 1, (i % 28) + 1))
.userRole(UserRole.ROLE_USER)
.agreedToTermsOfService(true)
Expand Down