use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class ShiroRealm method doGetAuthenticationInfo.
/**
* @方法描述: 验证当前登录的Subject
* @说明: 该方法的调用时机为LoginController.login()方法中执行Subject.login()时
* @param token
* @return
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authtoken) throws AuthenticationException {
UsernamePasswordToken token = (UsernamePasswordToken) authtoken;
// ① 获取当前登录的用户名
String currentUsername = token.getUsername();
String passWord = String.valueOf(token.getPassword());
SysUser sysUser = new SysUser();
SysUser currentUser = null;
SimpleAuthenticationInfo authcInfo = null;
try {
sysUser.setUserName(currentUsername);
int userCount = userService.getCountForJdbcParam(sysUser);
if (userCount <= 0) {
throw new UnknownAccountException();
}
currentUser = userService.checkUserExits(currentUsername, passWord);
} catch (Exception e) {
throw new UnknownAccountException();
}
if (currentUser != null) {
// 账号未通过审核
if (currentUser.getIfEnabled() != 1) {
throw new DisabledAccountException();
}
// 账号未通过审核
if (currentUser.getIfVisible() != 1) {
throw new DisabledAccountException("账号未通过审核");
}
// 账号不允许登录
if (currentUser.getLoginFlag() != 1) {
throw new AuthenticationException("账号不允许登录");
}
// 账号被锁定
if (currentUser.getIfLocked() != 1) {
throw new ExcessiveAttemptsException("账号被锁定");
}
WebUtilHelper.setCurrentLoginUser(currentUser);
authcInfo = new SimpleAuthenticationInfo(currentUser, currentUser.getPassword(), getName());
} else {
throw new LockedAccountException("用户名或密码错误");
}
return authcInfo;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class ManagerUserServiceImpl method getUserByName.
@Override
public SysUser getUserByName(String userName) throws Exception {
if (StringUtils.isNotBlank(userName)) {
SysUser user = new SysUser();
user.setUserName(userName);
return (SysUser) baseDao.findOneForJdbcParam(PREFIX + "findOneForJdbc", user);
} else {
return null;
}
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class WebUtilHelper method getCurrenLoginUser.
/**
* @方法:获取session里的用户对象
* @创建人:独泪了无痕
* @return
*/
public static final SysUser getCurrenLoginUser() {
HttpSession session = getSession();
SysUser sysUser = null;
if (session.getAttributeNames().hasMoreElements()) {
sysUser = (SysUser) session.getAttribute(GlobalConstants.USER_SESSION);
if (sysUser != null) {
return sysUser;
}
}
return sysUser;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method updateUserEnable.
@ResponseBody
@RequestMapping("enable")
@SystemLog(desc = " 启用账户", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson updateUserEnable(int userId) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(userId);
try {
SysUser sysUser = manageruserService.findOneForJdbc(user);
// 超级管理员不能操作
if (sysUser != null && sysUser.getUserType() != -1 && WebUtilHelper.getCurrentUserId() != userId) {
sysUser.setIfVisible(1);
manageruserService.update(sysUser);
}
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setResultCode(500);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
return resultMsg;
}
use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.
the class SysUserOperateController method saveRoleUser.
/**
* @方法描述: 用户-角色录入
* @创建者: 皇族灬战狼
* @创建时间: 2016年9月27日 下午4:51:27
* @param managerUser
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "roleAssign", params = "saveRoleUser")
@SystemLog(desc = "用户-角色录入(授权)", opType = SysOpType.INSERT, tableName = "sys_user_role")
public AjaxJson saveRoleUser(@RequestParam(value = "userCode", required = true) int id, @RequestParam(value = "roleID", defaultValue = "1", required = false) int roleID) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(id);
try {
if (roleID == 1) {
// 超级管理员不参与分配
resultMsg.setSuccess(false);
resultMsg.setMsg("无法授予权限");
}
SysUser tSUser = manageruserService.findOneForJdbc(user);
if (null == tSUser) {
resultMsg.setMsg("不存在");
resultMsg.setSuccess(false);
} else {
SysUserRole managerUserRole = new SysUserRole();
managerUserRole.setUserId(tSUser.getId());
managerUserRole.setRoleId(roleID);
manageruserService.saveRoleUser(managerUserRole);
}
} catch (Exception e) {
resultMsg.setResultCode(500);
resultMsg.setMsg("分配角色时出现异常");
resultMsg.setSuccess(false);
}
return resultMsg;
}
Aggregations