Skip to content

Commit

Permalink
[Hexlet#159] fix redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
d1z3d committed Jun 28, 2024
1 parent b376b45 commit b50fda8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public SecurityFilterChain filterChain(HttpSecurity http,
.userService(oAuth2UserService)
.and()
.successHandler(getOAuth2SuccessHandler())
.defaultSuccessUrl("/workspaces")
)
.csrf(csrf -> csrf
.ignoringRequestMatchers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public void onAuthenticationSuccess(HttpServletRequest request,
HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
CustomOAuth2User oAuth2User = (CustomOAuth2User) authentication.getPrincipal();
if (oAuth2User.getEmail() == null) {
//TODO: добавить ошибку на фронт, если email приватный
response.sendRedirect("/login");
}
accountService.processOAuthPostLogin(oAuth2User);
response.sendRedirect("/workspaces");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void processOAuthPostLogin(CustomOAuth2User user) {
account.setUsername(user.getLogin());
account.setPassword(user.getPassword());
account.setFirstName(user.getFirstName());
account.setLastName(user.getFirstName());
account.setLastName(user.getLastName());
accountRepository.save(account);
}
}
Expand Down

0 comments on commit b50fda8

Please sign in to comment.