关于Spring Security如何工作原理在这里就不介绍了。因为我也不懂
@Override
public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException {
String[] str = mobile.split(BusinessConstant.Constants.KEY_SPLIT_SYMBOL_2);
if(null == str) {
throw new LoginAccessException("请输入用户名");
} else if(1 == str.length) {
throw new LoginAccessException("请输入用户名不存在");
} else if(str.length > 2) {
throw new LoginAccessException("输入用户名不合法,请不要输入非法字符");
}
UserInfo record = userInfoMapper.findBymobile(str[0], str[1]);
if (record == null) {
throw new LoginAccessException("该用户不存在");
} else if(record.getStatus() != 1) {
throw new LoginAccessException("该用户已被禁用, 请联系管理员");
// throw new UsernameNotFoundException("该用户已不是正常状态, 请联系管理员");
}
List<GrantedAuthority> authorities=new ArrayList<>();
try {
//权限如果