|
@@ -1,12 +1,21 @@
|
|
|
package com.xt.js.gkaq.frame.system;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import javax.servlet.ServletRequest;
|
|
|
import javax.servlet.ServletResponse;
|
|
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.authc.AuthenticationToken;
|
|
|
+import org.apache.shiro.session.Session;
|
|
|
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import com.xt.js.gkaq.frame.model.GroupModelDto;
|
|
|
+import com.xt.js.gkaq.frame.model.MenuModel;
|
|
|
import com.xt.js.gkaq.frame.model.UserModel;
|
|
|
+import com.xt.js.gkaq.frame.service.GroupService;
|
|
|
+import com.xt.js.gkaq.frame.service.MenuService;
|
|
|
import com.yuanxd.tools.utils.Assert;
|
|
|
|
|
|
/**
|
|
@@ -16,13 +25,22 @@ import com.yuanxd.tools.utils.Assert;
|
|
|
*
|
|
|
*/
|
|
|
public class GkaqFormAuthenticationFilter extends FormAuthenticationFilter {
|
|
|
+ @Autowired
|
|
|
+ private GroupService groupService;
|
|
|
+ @Autowired
|
|
|
+ private MenuService menuService;
|
|
|
|
|
|
@Override
|
|
|
protected boolean onLoginSuccess(AuthenticationToken token, org.apache.shiro.subject.Subject subject,
|
|
|
ServletRequest request, ServletResponse response) throws Exception {
|
|
|
Object principal = subject.getPrincipal();
|
|
|
Assert.isInstanceOf(UserModel.class, principal);
|
|
|
- // UserModel u = (UserModel) principal;
|
|
|
+ // 根据当前用户获得授权的菜单并保存到会话
|
|
|
+ UserModel user = (UserModel) principal;
|
|
|
+ GroupModelDto userGroup = groupService.selectByUser(user.getId());
|
|
|
+ List<MenuModel> menuList = menuService.selectAllByUser(userGroup);
|
|
|
+ Session session = SecurityUtils.getSubject().getSession();
|
|
|
+ session.setAttribute(FrameParam.SESSION_KEY_MENUS, menuList);
|
|
|
return super.onLoginSuccess(token, subject, request, response);
|
|
|
}
|
|
|
|