hyuk2000s8968
@hyuk2000s8968
Reviews Written
2
Average Rating
5.0
Posts
Q&A
๋ชจ์์ฐธ๊ฐ ์ทจ์ ํ ๋ ๋ก์ง ์ง๋ฌธ
public Enrollment getTheFirstWaitingEnrollment() { return enrollments.stream() .filter(enrollment -> !enrollment.isAccepted()) // ๋๊ธฐ ์ค์ธ ๋ฉค๋ฒ๋ง ํํฐ๋ง .sorted(Comparator.comparing(Enrollment::getEnrolledAt)) // ์ ์ฒญ ์๊ฐ ๊ธฐ์ค ์ ๋ ฌ .findFirst() // ๊ฐ์ฅ ๋จผ์ ์ ์ฒญํ ๋ฉค๋ฒ ๋ฐํ .orElse(null); // ์์ผ๋ฉด null ๋ฐํ }์ด๋ ๊ฒํ๋ฉด ๋์ง์์๊น์ถ๋ค์
- Likes
- 0
- Comments
- 3
- Viewcount
- 352
Q&A
ํ์๊ฐ์ ์ฑ๊ณต ํ redirect์ด๋์ ๊ถํ ์ง๋ฌธ
๋ฆฌ๋ค์ด๋ ์ ์ดํ ์ธ์ ์ด ์ด๊ธฐํ ๋จ์ ๋ฐ๋ผ ๊ถํ ์ค์ ๋ ์ด๊ธฐํ๊ฐ ๋๊ฑฐ๊ฐ์์ ์ธ์ ์ SecurityContext๋ฅผ ๋ฐ์ํด ํด๊ฒฐํ์ด์// ์๋น์ค๋จ login๋ฉ์๋ public void login(Account account) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( new UserAccount(account), account.getPassword(), List.of(new SimpleGrantedAuthority("ROLE_USER"))); SecurityContextHolder.getContext().setAuthentication(token); // ์ธ์ ์ SecurityContext ๋ฐ์ HttpSession session = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest().getSession(); session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext()); }
- Likes
- 0
- Comments
- 3
- Viewcount
- 498




