|
@@ -13,6 +13,7 @@ import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
|
|
|
import javax.servlet.FilterChain;
|
|
import javax.servlet.FilterChain;
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.ServletException;
|
|
@@ -37,8 +38,8 @@ public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+ log.info("New login request!");
|
|
|
try {
|
|
try {
|
|
|
BufferedReader reader = request.getReader();
|
|
BufferedReader reader = request.getReader();
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
@@ -55,6 +56,10 @@ public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFi
|
|
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(email, password);
|
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(email, password);
|
|
|
return authenticationManager.authenticate(authenticationToken);
|
|
return authenticationManager.authenticate(authenticationToken);
|
|
|
}
|
|
}
|
|
|
|
|
+ catch (AuthenticationException e){
|
|
|
|
|
+ log.error("Error on auth");
|
|
|
|
|
+ throw new IllegalStateException(e.getMessage());
|
|
|
|
|
+ }
|
|
|
catch(IOException e){
|
|
catch(IOException e){
|
|
|
throw new IllegalArgumentException(e.getMessage());
|
|
throw new IllegalArgumentException(e.getMessage());
|
|
|
}
|
|
}
|