若依 4.2
This commit is contained in:
@ -92,7 +92,8 @@ public class DataScopeAspect
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param alias 别名
|
||||
* @param deptAlias 部门别名
|
||||
* @param userAlias 用户别名
|
||||
*/
|
||||
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias)
|
||||
{
|
||||
|
@ -254,6 +254,8 @@ public class ShiroConfig
|
||||
filterChainDefinitionMap.put("/logout", "logout");
|
||||
// 不需要拦截的访问
|
||||
filterChainDefinitionMap.put("/login", "anon,captchaValidate");
|
||||
// 注册相关
|
||||
filterChainDefinitionMap.put("/register", "anon,captchaValidate");
|
||||
// 系统权限列表
|
||||
// filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll());
|
||||
|
||||
|
@ -47,7 +47,7 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
|
||||
/**
|
||||
* 验证是否重复提交由子类实现具体的防重复提交的规则
|
||||
*
|
||||
* @param httpServletRequest
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.utils.AddressUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.framework.shiro.session.OnlineSession;
|
||||
import com.ruoyi.framework.util.LogUtils;
|
||||
@ -119,7 +120,7 @@ public class AsyncFactory
|
||||
logininfor.setOs(os);
|
||||
logininfor.setMsg(message);
|
||||
// 日志状态
|
||||
if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status))
|
||||
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
|
||||
{
|
||||
logininfor.setStatus(Constants.SUCCESS);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class SysPasswordService
|
||||
|
||||
public String encryptPassword(String username, String password, String salt)
|
||||
{
|
||||
return new Md5Hash(username + password + salt).toHex().toString();
|
||||
return new Md5Hash(username + password + salt).toHex();
|
||||
}
|
||||
|
||||
public void unlock(String loginName){
|
||||
|
@ -0,0 +1,80 @@
|
||||
package com.ruoyi.framework.shiro.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.ShiroConstants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 注册校验方法
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class SysRegisterService
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public String register(SysUser user)
|
||||
{
|
||||
String msg = "", username = user.getLoginName(), password = user.getPassword();
|
||||
|
||||
if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA)))
|
||||
{
|
||||
msg = "验证码错误";
|
||||
}
|
||||
else if (StringUtils.isEmpty(username))
|
||||
{
|
||||
msg = "用户名不能为空";
|
||||
}
|
||||
else if (StringUtils.isEmpty(password))
|
||||
{
|
||||
msg = "用户密码不能为空";
|
||||
}
|
||||
else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||
{
|
||||
msg = "密码长度必须在5到20个字符之间";
|
||||
}
|
||||
else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
||||
{
|
||||
msg = "账户长度必须在2到20个字符之间";
|
||||
}
|
||||
else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(username)))
|
||||
{
|
||||
msg = "保存用户'" + username + "'失败,注册账号已存在";
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setSalt(ShiroUtils.randomSalt());
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||
boolean regFlag = userService.registerUser(user);
|
||||
if (!regFlag)
|
||||
{
|
||||
msg = "注册失败,请联系系统管理人员";
|
||||
}
|
||||
else
|
||||
{
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success")));
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
@ -80,12 +80,12 @@ public class OnlineSessionDAO extends EnterpriseCacheSessionDAO
|
||||
boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L;
|
||||
|
||||
// session 数据变更了 同步
|
||||
if (isGuest == false && onlineSession.isAttributeChanged())
|
||||
if (!isGuest == false && onlineSession.isAttributeChanged())
|
||||
{
|
||||
needSync = true;
|
||||
}
|
||||
|
||||
if (needSync == false)
|
||||
if (!needSync)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class ConfigService
|
||||
/**
|
||||
* 根据键名查询参数配置信息
|
||||
*
|
||||
* @param configName 参数名称
|
||||
* @param configKey 参数键名
|
||||
* @return 参数键值
|
||||
*/
|
||||
public String getKey(String configKey)
|
||||
|
Reference in New Issue
Block a user