| | |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.all.SysService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | */ |
| | | @Configuration |
| | | public class AuthInterceptor implements HandlerInterceptor { |
| | | private TokenService tokenService; |
| | | private SysService sysService; |
| | | |
| | | private static final Log log = LogFactory.getLog(AuthInterceptor.class); |
| | | |
| | |
| | | |
| | | private static final String NO_AUTH = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NO_AUTH_ERROR, "无权限访问")); |
| | | |
| | | public AuthInterceptor(TokenService tokenService) { |
| | | this.tokenService = tokenService; |
| | | public AuthInterceptor(SysService sysService) { |
| | | this.sysService = sysService; |
| | | } |
| | | |
| | | /** |
| | |
| | | return WebHelper.write2Page(response, NO_TOKEN); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(request); |
| | | //String ip = WebHelper.getIpAddress(request); |
| | | //List<String> blackList= |
| | | |
| | | UserEntity ue = sysService.tokenService.getCurrentUser(request); |
| | | if (ue == null) { |
| | | return WebHelper.write2Page(response, NO_LOGIN); |
| | | } |
| | | |
| | | if (tokenService.isUidDisable(ue)) { |
| | | if (sysService.tokenService.isUidDisable(ue)) { |
| | | return WebHelper.write2Page(response, USER_LOCK); |
| | | } |
| | | |
| | |
| | | * 检查权限 |
| | | */ |
| | | private boolean checkPerms(UserEntity ue, HttpServletRequest request) { |
| | | List<String> list = tokenService.permsService.selectPerms(ue.getUid()); |
| | | List<String> list = sysService.permsService.selectPerms(ue.getUid()); |
| | | if (list == null || list.size() == 0) { |
| | | return false; |
| | | } |