|
@@ -1,40 +0,0 @@
|
|
|
-package com.ym.mec.auth.core.provider.service;
|
|
|
-
|
|
|
-import com.ym.mec.auth.api.dto.SysUserInfo;
|
|
|
-import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.auth.service.SysUserService;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.authentication.LockedException;
|
|
|
-import org.springframework.security.core.GrantedAuthority;
|
|
|
-import org.springframework.security.core.authority.AuthorityUtils;
|
|
|
-import org.springframework.security.core.userdetails.User;
|
|
|
-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.Service;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-@Service
|
|
|
-public class PhoneUserDetailService implements UserDetailsService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysUserService sysUserService;
|
|
|
-
|
|
|
- @Override
|
|
|
- public UserDetails loadUserByUsername(String phone) throws UsernameNotFoundException {
|
|
|
- SysUserInfo userInfo = sysUserService.queryUserInfoByPhone(phone);
|
|
|
- if(userInfo == null){
|
|
|
- return null;
|
|
|
- }else if(StringUtils.equals(userInfo.getSysUser().getLockFlag(),"9")){
|
|
|
- throw new LockedException("账户被锁定");
|
|
|
- }
|
|
|
- List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList(userInfo.getPermissions());
|
|
|
-
|
|
|
- SysUser sysUser = userInfo.getSysUser();
|
|
|
-
|
|
|
- return new User(phone, "", StringUtils.equals(sysUser.getLockFlag(), "0"), true, true, true,
|
|
|
- authorities);
|
|
|
- }
|
|
|
-
|
|
|
-}
|