| | |
| | | |
| | | ArrayList<GrantedAuthority> grantedAuthorities = new ArrayList<>(); |
| | | // 赋予部门管理员角色 |
| | | if (DeptAdminEnum.YES.getValue().equals(user.getDeptAdmin())) { |
| | | if (new Integer(-1).equals(user.getRole())) { |
| | | grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.DEPT_ADMIN.getRoleName())); |
| | | } |
| | | grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.fromCode(user.getRole()).getRoleName())); |
| | |
| | | import com.mindskip.xzs.domain.UserEventLog; |
| | | import com.mindskip.xzs.event.UserEvent; |
| | | import com.mindskip.xzs.service.UserService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.security.core.Authentication; |
| | |
| | | // 静态资源,可匿名访问 |
| | | // todo 设置部门管理员可以看的请求 |
| | | .antMatchers("/api/admin/**").hasAnyRole(RoleEnum.ADMIN.getName(), RoleEnum.DEPT_ADMIN.getName()) |
| | | .antMatchers("/api/student/**").hasRole(RoleEnum.STUDENT.getName()) |
| | | .antMatchers("/api/student/**").hasAnyRole(RoleEnum.STUDENT.getName(), RoleEnum.DEPT_ADMIN.getName()) |
| | | .anyRequest().permitAll() |
| | | .and().exceptionHandling().accessDeniedHandler(restAccessDeniedHandler) |
| | | .and().formLogin().successHandler(restAuthenticationSuccessHandler).failureHandler(restAuthenticationFailureHandler) |