Merge pull request #709 from lor6/custom-userservice-new-project

update loaduserbyusername
This commit is contained in:
Prashant Khanal 2016-09-30 10:54:23 -07:00 committed by GitHub
commit df25f34b06
1 changed files with 3 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package org.baeldung.security;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import org.baeldung.persistence.model.MyUser;
@ -27,11 +28,8 @@ public class MyUserDetailsService implements UserDetailsService {
if (user == null) {
throw new UsernameNotFoundException("No user found with username: " + username);
}
else {
final Collection<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
return new User(user.getUsername(), user.getPassword(), authorities);
}
return new User(user.getUsername(), user.getPassword(), Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")));
}
}