Guest User

Untitled

a guest
Mar 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. @RestController("/api/v1/users")
  2. public class UserController {
  3.  
  4.  
  5. @RequestMapping(value = "/login", method = RequestMethod.GET)
  6. public List<User> getUserByEmailAndPassword(@RequestParam("email") String email, @RequestParam("password") String password) {
  7. logger.info("Request to get user with email and password: " + email + password);
  8. User user = userService.checkUserByEmailAndPassword(email, password);
  9. return user != null ? Collections.singletonList(user) : Collections.emptyList();
  10. }
  11.  
  12. @RequestMapping(method = RequestMethod.GET)
  13. public List<UserDto> getUserByEmail(@RequestParam("email") String email) {
  14. logger.info("Request to get user with email: " + email);
  15. UserDto userDto = userService.checkUserEmail(email);
  16. return userDto != null ? Collections.singletonList(userDto) : Collections.emptyList();
  17. }
  18. }
  19.  
  20. @Configuration
  21. public class CorsConfig {
  22.  
  23. @Bean
  24. public FilterRegistrationBean corsFilter() {
  25. UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  26. CorsConfiguration config = new CorsConfiguration();
  27. config.setAllowCredentials(true);
  28. config.addAllowedOrigin("*");
  29. config.addAllowedHeader("*");
  30. config.addAllowedMethod("*");
  31. source.registerCorsConfiguration("/**", config);
  32. FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
  33. bean.setOrder(0);
  34. return bean;
  35. }
  36. }
Add Comment
Please, Sign In to add comment