Changeset 46fd0c7 for src/main/java/edu/gjoko/schedlr/config
- Timestamp:
- 03/13/23 00:58:07 (20 months ago)
- Branches:
- master
- Children:
- 9050790
- Parents:
- 2b0a4db
- Location:
- src/main/java/edu/gjoko/schedlr/config
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/config/AppFilter.java
r2b0a4db r46fd0c7 4 4 import org.springframework.security.core.context.SecurityContextImpl; 5 5 import org.springframework.security.core.userdetails.UserDetails; 6 import org.springframework.util.StringUtils; 6 7 import org.springframework.web.filter.GenericFilterBean; 7 8 … … 23 24 HttpSession session = httpServletRequest.getSession(false); 24 25 26 if(httpServletRequest.getRequestURI().endsWith(".js") || httpServletRequest.getRequestURI().endsWith(".css")) { 27 filterChain.doFilter(servletRequest, servletResponse); 28 return; 29 } 25 30 if(session != null) { 26 31 Map<String, String> roleTargetUrlMap = new HashMap<>(); 27 roleTargetUrlMap.put("ADMIN", "/ date");28 roleTargetUrlMap.put("CUSTOMER", "/ number");29 roleTargetUrlMap.put("BUSINESS_OWNER", " ");32 roleTargetUrlMap.put("ADMIN", "/admin"); 33 roleTargetUrlMap.put("CUSTOMER", "/homepage"); 34 roleTargetUrlMap.put("BUSINESS_OWNER", "/business_homepage"); 30 35 SecurityContextImpl sci = (SecurityContextImpl) session.getAttribute("SPRING_SECURITY_CONTEXT"); 31 36 if(sci != null) { … … 34 39 for (final GrantedAuthority grantedAuthority : authorities) { 35 40 String authorityName = grantedAuthority.getAuthority(); 36 if("DATE".equalsIgnoreCase(authorityName)) { 37 servletRequest.getRequestDispatcher("date").forward(servletRequest, servletResponse); 38 return; 39 } else if("GUESS_NUMBER".equalsIgnoreCase(authorityName)) { 40 try { 41 servletRequest.getRequestDispatcher("number").forward(servletRequest, servletResponse); 42 } catch (Exception e) { 43 e.printStackTrace(); 44 } 45 41 String page = ""; 42 switch (authorityName) { 43 case "ADMIN": 44 page = "/admin"; 45 break; 46 case "CUSTOMER": 47 case "BUSINESS_OWNER": 48 page = "/homepage"; 49 break; 50 default: 51 break; 52 } 53 if(page != null && !page.trim().isEmpty()) { 54 servletRequest.getRequestDispatcher(page).forward(servletRequest, servletResponse); 46 55 return; 47 56 } -
src/main/java/edu/gjoko/schedlr/config/AppSecurityConfig.java
r2b0a4db r46fd0c7 60 60 .antMatchers("/register_business").permitAll() 61 61 .antMatchers("/api/nomenclatures/*").permitAll() 62 .antMatchers("/api/business").permitAll() 62 63 .antMatchers("/homepage").permitAll() 63 64 .antMatchers("/css/**").permitAll() -
src/main/java/edu/gjoko/schedlr/config/MvcConfig.java
r2b0a4db r46fd0c7 2 2 3 3 import org.springframework.context.annotation.Configuration; 4 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 4 5 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 5 6 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; … … 14 15 registry.addViewController("/register_business").setViewName("register_business"); 15 16 registry.addViewController("/homepage").setViewName("homepage"); 17 registry.addViewController("/admin").setViewName("admin"); 16 18 } 17 19 18 20 @Override 21 public void addResourceHandlers(ResourceHandlerRegistry registry) { 22 registry.addResourceHandler("/resources/**") 23 .addResourceLocations("/resources/"); 24 } 19 25 }
Note:
See TracChangeset
for help on using the changeset viewer.