1
This commit is contained in:
@@ -50,6 +50,10 @@
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-file</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
package cn.fateverse.auth.service;
|
||||
|
||||
import cn.fateverse.admin.dubbo.DubboUserService;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.core.enums.UserState;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2022/10/27
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Service
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@DubboReference
|
||||
private DubboUserService userService;
|
||||
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
//todo 编辑用户登录相关逻辑
|
||||
log.info("有用户登录:{}",username);
|
||||
User user = userService.getUserByUsername(username);
|
||||
log.info("有用户登录:{}", username);
|
||||
UserDetail user = userService.getUserDetailsByUserName(username);
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package cn.fateverse.auth.service.impl;
|
||||
|
||||
import cn.fateverse.auth.entity.UserInfo;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.fateverse.admin.dubbo.DubboMenuService;
|
||||
import cn.fateverse.admin.dubbo.DubboUserService;
|
||||
import cn.fateverse.admin.vo.RouterVo;
|
||||
import cn.fateverse.auth.entity.LoginBody;
|
||||
import cn.fateverse.auth.entity.UserInfo;
|
||||
import cn.fateverse.auth.event.LoginInfoEvent;
|
||||
import cn.fateverse.auth.service.LoginService;
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.auth.utils.LoginInfoUtil;
|
||||
import cn.fateverse.common.core.constant.CacheConstants;
|
||||
import cn.fateverse.common.core.constant.DateConstants;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.exception.UserPasswordNotMatchException;
|
||||
import cn.fateverse.common.core.utils.SpringContextHolder;
|
||||
import cn.fateverse.common.core.utils.uuid.IdUtils;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.fateverse.auth.event.LoginInfoEvent;
|
||||
import cn.fateverse.auth.utils.LoginInfoUtil;
|
||||
import cn.fateverse.log.entity.LoginInfo;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.redisson.api.RLock;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package cn.fateverse.auth.service.impl;
|
||||
|
||||
import cn.fateverse.admin.dubbo.DubboMenuService;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -27,9 +28,9 @@ public class PermissionService {
|
||||
* @param loginUser 登录用户
|
||||
*/
|
||||
public void getMenuPermission(LoginUser loginUser) {
|
||||
User user = loginUser.getUser();
|
||||
UserDetail user = loginUser.getUser();
|
||||
Set<String> perms = new HashSet<>();
|
||||
if (user.isAdmin()) {
|
||||
if (SecurityUtils.isAdmin(user.getUserId())) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
Set<String> menuSet = menuService.selectMenuPermsByUserId(user.getUserId());
|
||||
|
||||
Reference in New Issue
Block a user