15 Commits

Author SHA1 Message Date
646c37ea57 [ADD]認証機能の作成 2026-09-17 15:33:17 +09:00
kkazuya
6b91c91c19 [ADD] Course, CourseInfoFormを作成しました 2026-09-17 14:29:59 +09:00
s-choi
1c5cb6bf7a [HOTFIX] Entityのキーを再定義しました。 2026-09-17 14:28:44 +09:00
s-choi
e2286762d6 [ADD] Allocationの複合キークラスを作成しました。 2026-09-17 14:27:59 +09:00
kkazuya
0c19adb63f Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-17 14:20:43 +09:00
kkazuya
f86d47c17a [EDIT] AllocationRepositoryにコース一覧に表示するデータを取得する@Queryを追加しました 2026-09-17 14:20:34 +09:00
a98554ac69 Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-17 14:17:43 +09:00
s-choi
cf31d03415 [FIX] IDの型を修正しました。 2026-09-17 14:16:19 +09:00
s-choi
80d83b96f4 [FIX] import及び型の修正を行いました。 2026-09-17 14:15:59 +09:00
kkazuya
7f828657ad [ADD] Allocation, CourseのModelを追加しました。 2026-09-17 14:09:06 +09:00
kkazuya
064b74c49b Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-17 14:04:29 +09:00
kkazuya
4fc69cddb3 [EDIT] Course, AllocationEntityのテーブル名を修正 2026-09-17 14:04:20 +09:00
72477d014b Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito 2026-09-17 13:02:47 +09:00
kkazuya
792172664c Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-17 12:44:49 +09:00
kkazuya
882212aed5 Merge branch 's-morimto' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi 2026-09-17 11:24:54 +09:00
7 changed files with 187 additions and 4 deletions

View File

@@ -0,0 +1,10 @@
package com.example.demo.app.domain.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public class AuthenticationModel {
private Long userId;
}

View File

@@ -8,10 +8,9 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public class UserModel {
private Long userId;
private String userName;
private String emailAddress;
private String mailAddress;
private String password;
private Integer secretQuestionId;
private String secretAnswer;
@@ -19,7 +18,7 @@ public class UserModel {
private Integer saving;
private Integer annualIncome;
private Integer monthlyBudget;
private Integer goalId;
private Integer courseId;
private Long goalId;
private Long courseId;
private Integer deleteFlag;
}

View File

@@ -0,0 +1,9 @@
package com.example.demo.app.domain.service;
import com.example.demo.app.domain.model.AuthenticationModel;
import com.example.demo.app.presentation.form.AuthenticationForm;
public interface AuthenticationService {
AuthenticationModel authenticate(AuthenticationForm authenticationForm);
}

View File

@@ -0,0 +1,42 @@
package com.example.demo.app.domain.service.impl;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.AuthenticationModel;
import com.example.demo.app.domain.service.AuthenticationService;
import com.example.demo.app.infra.entity.UserEntity;
import com.example.demo.app.infra.repository.UserRepository;
import com.example.demo.app.presentation.form.AuthenticationForm;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class AuthenticationServiceImpl implements AuthenticationService {
private final UserRepository userRepository;
@Override
public AuthenticationModel authenticate(AuthenticationForm authenticationForm) {
UserEntity userEntity = userRepository.findByMailAddress(
authenticationForm.getMailAddress())
.orElse(null);
if (userEntity == null) {
return null;
}
if (!userEntity.getQuestionEntity().getSecretQuestionId()
.equals(authenticationForm.getSecretQuestionId())) {
return null;
}
if (!userEntity.getSecretQuestionAnswer()
.equals(authenticationForm.getSecretAnswer())) {
return null;
}
return new AuthenticationModel(userEntity.getUserId());
}
}

View File

@@ -0,0 +1,56 @@
package com.example.demo.app.presentation.controller;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.app.domain.model.AuthenticationModel;
import com.example.demo.app.domain.service.AuthenticationService;
import com.example.demo.app.infra.repository.QuestionRepository;
import com.example.demo.app.presentation.form.AuthenticationForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class AuthenticationController {
private final AuthenticationService authenticationService;
private final QuestionRepository questionRepository;
@GetMapping("/authentication")
public String showAuthentication(Model model) {
model.addAttribute("authenticationForm", new AuthenticationForm());
model.addAttribute("questionList", questionRepository.findAll());
return "authentication";
}
@PostMapping("/authentication")
public String authenticate(
AuthenticationForm authenticationForm,
Model model,
HttpSession session) {
AuthenticationModel authenticationModel =
authenticationService.authenticate(authenticationForm);
if (authenticationModel == null) {
model.addAttribute("errorMessage", "認証情報が正しくありません。");
model.addAttribute("questionList", questionRepository.findAll());
return "authentication";
}
session.setAttribute(
"passwordResetUserId",
authenticationModel.getUserId());
return "password_reset";
}
}

View File

@@ -0,0 +1,14 @@
package com.example.demo.app.presentation.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AuthenticationForm {
private String mailAddress;
private Integer secretQuestionId;
private String secretAnswer;
}

View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>認証</title>
</head>
<body>
<main>
<h1>本人認証確認</h1>
<form th:action="@{/authentication}" th:object="${authenticationForm}" method="post">
<div>
<label for="mailAddress">メールアドレス</label>
<input type="email" id="mailAddress" th:field="*{mailAddress}">
</div>
<div>
<label for="secretQuestionId">秘密の質問</label>
<select id="secretQuestionId" th:field="*{secretQuestionId}">
<option value="">選択してください</option>
<option th:each="question : ${questionList}" th:value="${question.secretQuestionId}"
th:text="${question.questionText}">
</option>
</select>
</div>
<div>
<label for="secretAnswer">秘密の質問の回答</label>
<input type="text" id="secretAnswer" th:field="*{secretAnswer}">
</div>
<button type="submit">確認</button>
</form>
<form th:action="@{/login}" method="get">
<button type="submit">戻る</button>
</form>
</main>
<script th:if="${errorMessage}" th:inline="javascript">
alert(/*[[${errorMessage}]]*/);
</script>
</body>
</html>