-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor/user problem number #185
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
Changes from 3 commits
8eb45f9
3d4b88c
36a7244
1258cfb
1cbb68a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,21 @@ | ||
| package org.ezcode.codetest.domain.submission.dto; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| public record DailyCorrectCount( | ||
| LocalDate date, | ||
| int count | ||
| int count, | ||
| List<Long> problemIds | ||
| ) { | ||
| public DailyCorrectCount(java.sql.Date date, int count) { | ||
| this(date.toLocalDate(), count); | ||
|
|
||
| public DailyCorrectCount(java.sql.Date date, Set<Long> problemIds) { | ||
| this( | ||
| date.toLocalDate(), | ||
| problemIds.size(), | ||
| new ArrayList<>(problemIds) | ||
| ); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,7 +51,7 @@ public MimeMessage CreateButtonMail(Long userId, String email, String redirectUr | |||||||||||||||||||||||||||||||||||||||||||
| String body = ""; | ||||||||||||||||||||||||||||||||||||||||||||
| body += "<h3>" + "아래 버튼을 클릭하여 이메일 인증을 완료해 주세요" + "</h3>"; | ||||||||||||||||||||||||||||||||||||||||||||
| // 이메일 버튼 | ||||||||||||||||||||||||||||||||||||||||||||
| body += "<a href='" + redirectUrl + "/api/auth/verify?email="+ email + "&key=" + key + "' target='_blenk'>이메일 인증 확인</a>"; | ||||||||||||||||||||||||||||||||||||||||||||
| body += "<a href='" + redirectUrl + "/api/auth/verify-page?email="+ email + "&key=" + key + "' target='_blenk'>이메일 인증 확인</a>"; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
| body += "<a href='" + redirectUrl + "/api/auth/verify-page?email="+ email + "&key=" + key + "' target='_blenk'>이메일 인증 확인</a>"; | |
| // add at top of file | |
| import org.springframework.web.util.UriComponentsBuilder; | |
| … | |
| public MimeMessage CreateButtonMail(…) { | |
| … | |
| // build a safe, encoded verification link using the configured base URL | |
| String href = UriComponentsBuilder | |
| .fromHttpUrl(backendPublicBaseUrl) | |
| .path("/api/auth/verify-page") | |
| .queryParam("email", email) | |
| .queryParam("key", key) | |
| .build() | |
| .toUriString(); | |
| // use the new href and correct the target typo | |
| body += "<a href=\"" + href + "\" target=\"_blank\">이메일 인증 확인</a>"; | |
| … | |
| } |
🤖 Prompt for AI Agents
In src/main/java/org/ezcode/codetest/domain/user/service/MailService.java around
line 54, stop using the client-supplied redirectUrl and instead build the
verification link using the configured app.backend.public-base-url as the host;
construct the URL with Spring's UriComponentsBuilder (set the base URL, path
/api/auth/verify-page, and add email and key as query parameters so they are
percent-encoded) and use the builtUriString() result for the href, and fix the
anchor target typo from '_blenk' to '_blank'; apply the same target '_blank' fix
to CreatePasswordMail as well.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -159,4 +159,12 @@ spring.datasource.hikari.minimum-idle=10 | |||||||||||||||||||||||||||||||||||
| spring.datasource.hikari.idle-timeout=30000 | ||||||||||||||||||||||||||||||||||||
| spring.datasource.hikari.max-lifetime=600000 | ||||||||||||||||||||||||||||||||||||
| spring.datasource.hikari.connection-timeout=30000 | ||||||||||||||||||||||||||||||||||||
| spring.datasource.hikari.validation-timeout=5000 | ||||||||||||||||||||||||||||||||||||
| spring.datasource.hikari.validation-timeout=5000 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # ======================== | ||||||||||||||||||||||||||||||||||||
| # App Redirects (Email Verify) | ||||||||||||||||||||||||||||||||||||
| # ======================== | ||||||||||||||||||||||||||||||||||||
| # 인증 성공 시 이동할 페이지 URL (예: 프론트의 성공 안내 페이지) | ||||||||||||||||||||||||||||||||||||
| app.redirect.verify.success=${APP_REDIRECT_VERIFY_SUCCESS:https://your-frontend.example.com/verify/success} | ||||||||||||||||||||||||||||||||||||
| # 인증 실패 시 이동할 페이지 URL (예: 프론트의 실패 안내 페이지) | ||||||||||||||||||||||||||||||||||||
| app.redirect.verify.failure=${APP_REDIRECT_VERIFY_FAILURE:https://your-frontend.example.com/verify/failure} | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+164
to
+170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 리다이렉트 속성 추가는 적절. 메일 링크용 백엔드 베이스 URL 속성도 함께 정의 권장 메일 링크 호스트를 신뢰 가능한 설정에서 주입받을 수 있도록 백엔드 퍼블릭 베이스 URL 속성을 추가하세요. # ========================
# App Redirects (Email Verify)
# ========================
+# 백엔드 퍼블릭 베이스 URL (메일 인증 링크 생성 시 사용)
+app.backend.public-base-url=${APP_BACKEND_PUBLIC_BASE_URL:https://api.your-backend.example.com}
+
# 인증 성공 시 이동할 페이지 URL (예: 프론트의 성공 안내 페이지)
app.redirect.verify.success=${APP_REDIRECT_VERIFY_SUCCESS:https://your-frontend.example.com/verify/success}
# 인증 실패 시 이동할 페이지 URL (예: 프론트의 실패 안내 페이지)
app.redirect.verify.failure=${APP_REDIRECT_VERIFY_FAILURE:https://your-frontend.example.com/verify/failure}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
닉네임 중복 선검사만으로는 부족 — DB 유니크 제약과 예외 매핑 병행 필요
현재 선검사로는 경쟁 상태를 막지 못합니다. 유니크 제약 추가 후
DataIntegrityViolationException을ALREADY_EXIST_NICKNAME으로 매핑하는 방식을 병행하세요. 또한 공백/대소문자 정규화도 고려 바랍니다.정규화 예시:
🤖 Prompt for AI Agents