|
|
@@ -10,6 +10,7 @@ import org.apache.shiro.util.StringUtils;
|
|
|
import org.apache.shiro.web.filter.AccessControlFilter;
|
|
|
import org.apache.shiro.web.util.WebUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
import com.goafanti.common.bo.Error;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
@@ -20,6 +21,9 @@ public class PermissionFilter extends AccessControlFilter {
|
|
|
|
|
|
@Autowired
|
|
|
private ShiroFilterUtils shiroFilterUtils;
|
|
|
+
|
|
|
+ @Value("app.mobile.website")
|
|
|
+ private String mobileWebsite;
|
|
|
|
|
|
@Override
|
|
|
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
|
|
|
@@ -44,7 +48,10 @@ public class PermissionFilter extends AccessControlFilter {
|
|
|
@Override
|
|
|
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
|
|
|
Subject subject = getSubject(request, response);
|
|
|
- if (shiroFilterUtils.isAjax((HttpServletRequest) request)) {
|
|
|
+ if (shiroFilterUtils.isMobileDevice((HttpServletRequest)request)){
|
|
|
+ LoggerUtils.debug(getClass(), "当前访问为移动设备");
|
|
|
+ WebUtils.issueRedirect(request, response, mobileWebsite);
|
|
|
+ }else if (shiroFilterUtils.isAjax((HttpServletRequest) request)) {
|
|
|
LoggerUtils.debug(getClass(), "当前用户权限不够,并且是Ajax请求!");
|
|
|
shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户权限不够!")));
|
|
|
} else if (null == subject.getPrincipal()) {
|