ADD SessionUtils
- LoginAccountProcessor 누락된 이메일 검증 추가 - build.grade 필요없는 주석 삭제
This commit is contained in:
@@ -91,19 +91,19 @@ jacocoTestCoverageVerification {
|
||||
"*.*Repository",
|
||||
"*.*Reader",
|
||||
"*.Role",
|
||||
"*.configuration.*", // path/configuration/...
|
||||
"*.configuration.*",
|
||||
"*.SmtpMail*",
|
||||
"*.RoleTypeHandler",
|
||||
]
|
||||
|
||||
limit {
|
||||
counter = 'BRANCH' // 모든 분기가 실행되는가?
|
||||
counter = 'BRANCH'
|
||||
value = 'COVEREDRATIO'
|
||||
minimum = 0.80
|
||||
}
|
||||
|
||||
limit {
|
||||
counter = 'INSTRUCTION' // 바이트코드 라인 커버리지
|
||||
counter = 'INSTRUCTION'
|
||||
value = 'COVEREDRATIO'
|
||||
minimum = 0.50
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public final class LoginAccountProcessor {
|
||||
|
||||
public void login(String email, String password) {
|
||||
var account = accountReader.findByEmail(email)
|
||||
.filter(Account::isEmailVerified)
|
||||
.orElseThrow(IllegalStateException::new);
|
||||
|
||||
if (!passwordEncrypter.matches(password, account.getPassword())) {
|
||||
|
||||
@@ -32,6 +32,7 @@ public final class AccountQueryApi {
|
||||
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
SessionUtils.setLoginAccountEmail(request.getEmail());
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yam.app.account.presentation;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
public final class SessionUtils {
|
||||
|
||||
public static final String LOGIN_ACCOUNT_EMAIL = "LOGIN_ACCOUNT_EMAIL";
|
||||
|
||||
private SessionUtils() {
|
||||
}
|
||||
|
||||
public static String getLoginAccountEmail() {
|
||||
return (String) getHttpSession().getAttribute(LOGIN_ACCOUNT_EMAIL);
|
||||
}
|
||||
|
||||
public static void setLoginAccountEmail(String email) {
|
||||
getHttpSession().setAttribute(LOGIN_ACCOUNT_EMAIL, email);
|
||||
}
|
||||
|
||||
private static HttpSession getHttpSession() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
|
||||
.getRequest()
|
||||
.getSession(true);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ class LoginAccountProcessorTest {
|
||||
var loginAccountProcessor = new LoginAccountProcessor(accountReader, passwordEncrypter);
|
||||
|
||||
var account = Account.of("hello@naver.com", "hello", "password!");
|
||||
account.completeRegister();
|
||||
accountRepository.save(account);
|
||||
|
||||
return Arrays.asList(
|
||||
|
||||
Reference in New Issue
Block a user