修改密码退出登陆后端
parent
04639237e5
commit
126c8e1fe6
|
@ -44,19 +44,19 @@ public class SysLoginService {
|
|||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||
throw new ServiceException("邮箱必须填写");
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
}
|
||||
// 密码如果不在指定范围内 错误
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||
throw new ServiceException("邮箱范围");
|
||||
throw new ServiceException("用户密码不在指定范围");
|
||||
}
|
||||
// 用户名不在指定范围内 错误
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||
throw new ServiceException("邮箱范围");
|
||||
throw new ServiceException("用户名不在指定范围");
|
||||
}
|
||||
// IP黑名单校验
|
||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
||||
|
@ -80,11 +80,11 @@ public class SysLoginService {
|
|||
SysUser user = userResult.getData().getSysUser();
|
||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||
throw new ServiceException("对不起,您的邮箱:" + username + " 已被删除");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||
}
|
||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的邮箱:" + username + " 已停用");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
passwordService.validate(user, password);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
|
@ -122,6 +122,7 @@ public class SysLoginService {
|
|||
if (Result.FAIL == registerResult.getCode()) {
|
||||
throw new ServiceException(registerResult.getMsg());
|
||||
}
|
||||
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -24,8 +24,9 @@ public interface RemoteUserService {
|
|||
*
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@GetMapping("/user/info/{username}")
|
||||
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
public Result<LoginUser> getUserInfo (@PathVariable(name = "username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
|
@ -37,4 +38,5 @@ public interface RemoteUserService {
|
|||
*/
|
||||
@PostMapping("/user/register")
|
||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
|||
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
||||
.captchaEnabled(captchaEnabled);
|
||||
if (!captchaEnabled) {
|
||||
|
||||
return Result.success(respBuilder);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.JwtUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.annotation.InnerAuth;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.service.TokenService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
|
@ -17,6 +22,7 @@ import com.muyu.common.system.domain.LoginUser;
|
|||
import com.muyu.system.domain.resp.AuthRoleResp;
|
||||
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
||||
import com.muyu.system.domain.resp.UserInfoResp;
|
||||
import com.muyu.system.mapper.SysUserMapper;
|
||||
import com.muyu.system.service.*;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -26,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -44,6 +51,9 @@ public class SysUserController extends BaseController {
|
|||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private SysDeptService deptService;
|
||||
|
||||
|
@ -96,9 +106,13 @@ public class SysUserController extends BaseController {
|
|||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
// @GetMapping("/user/info/{username}")
|
||||
|
||||
// public Result<LoginUser> getUserInfo (@PathVariable(name="username")
|
||||
// String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
@InnerAuth
|
||||
@GetMapping("/info/{username}")
|
||||
public Result<LoginUser> info (@PathVariable("username") String username) {
|
||||
public Result<LoginUser> getUserInfo (@PathVariable(name="username") String username) {
|
||||
SysUser sysUser = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(sysUser)) {
|
||||
return Result.error("用户名或密码错误");
|
||||
|
@ -172,6 +186,7 @@ public class SysUserController extends BaseController {
|
|||
.roleIds(sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()))
|
||||
.build();
|
||||
}
|
||||
|
||||
return Result.success(builder.build());
|
||||
}
|
||||
|
||||
|
@ -214,6 +229,8 @@ public class SysUserController extends BaseController {
|
|||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
|
@ -224,6 +241,20 @@ public class SysUserController extends BaseController {
|
|||
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
|
||||
String ids= null;
|
||||
for (Long userId : userIds) {
|
||||
ids = "," + userIds;
|
||||
}
|
||||
ids.substring(1);
|
||||
List<LoginUser> list = userService.getUser(ids);
|
||||
// list.stream()
|
||||
// .map(
|
||||
// user ->{
|
||||
// return tokenService.createToken()
|
||||
// }
|
||||
// )
|
||||
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -46,7 +47,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
*
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName (@Param("userName") String userName);
|
||||
public SysUser selectUserByUserName (String userName);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -139,4 +140,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique (String email);
|
||||
|
||||
List<LoginUser> getIds(@Param("ids") String ids);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -225,4 +227,7 @@ public interface SysUserService extends IService<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
|
||||
List<LoginUser> getUser(String ids);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import com.muyu.common.core.utils.bean.BeanValidators;
|
||||
import com.muyu.common.datascope.annotation.DataScope;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.SysPost;
|
||||
|
@ -111,6 +112,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
*/
|
||||
@Override
|
||||
public SysUser selectUserById (Long userId) {
|
||||
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
|
@ -500,4 +502,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoginUser> getUser(String ids) {
|
||||
return userMapper.getIds(ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 124.222.161.68:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -152,7 +152,7 @@
|
|||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.email = #{userName} and
|
||||
where u.email = #{userName} or u.user_name = #{userName} and
|
||||
u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
|
@ -184,6 +184,10 @@
|
|||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
<select id="getIds" resultType="com.muyu.common.system.domain.LoginUser">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id in #{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
|
Loading…
Reference in New Issue