use of tk.ainiyue.danyuan.application.softm.sysmenu.po.SysMenuInfo in project danyuan-application by 514840279.
the class CustomUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
SysUserBaseInfo user;
try {
user = sysUserBaseService.findByName(userName);
} catch (Exception e) {
throw new UsernameNotFoundException("user select fail");
}
if (user == null) {
throw new UsernameNotFoundException("no user found");
} else {
try {
List<SysMenuInfo> menu = sysUserBaseService.getRoleByUser(user.getUuid());
List<GrantedAuthority> gas = new ArrayList<>();
if (menu != null) {
for (SysMenuInfo sysMenuInfo : menu) {
gas.add(new SimpleGrantedAuthority(sysMenuInfo.getName()));
}
}
// gas.add(new SwitchUserGrantedAuthority("ROLE_USER", new Authentication()));
UserDetails users = new User(user.getUserName(), user.getPassword(), true, true, true, true, gas);
return users;
} catch (Exception e) {
throw new UsernameNotFoundException("user role select fail");
}
}
}
Aggregations