first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package net.alawn.bill.security;
|
||||
|
||||
import net.alawn.bill.entity.po.User;
|
||||
import net.alawn.bill.repository.UserRepo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 16:46 2019-05-20
|
||||
*/
|
||||
@Service("authUserDetailsService")
|
||||
public class AuthUserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private UserRepo userRepo;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
|
||||
|
||||
User user = userRepo.findByUsername(name);
|
||||
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("UsernameNotFoundException");
|
||||
} else {
|
||||
return UserFactory.createAuthUser(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user