Merge pull request #709 from lor6/custom-userservice-new-project
update loaduserbyusername
This commit is contained in:
commit
df25f34b06
|
@ -1,6 +1,7 @@
|
||||||
package org.baeldung.security;
|
package org.baeldung.security;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.baeldung.persistence.model.MyUser;
|
import org.baeldung.persistence.model.MyUser;
|
||||||
|
@ -27,11 +28,8 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new UsernameNotFoundException("No user found with username: " + username);
|
throw new UsernameNotFoundException("No user found with username: " + username);
|
||||||
}
|
}
|
||||||
else {
|
return new User(user.getUsername(), user.getPassword(), Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")));
|
||||||
final Collection<GrantedAuthority> authorities = new ArrayList<>();
|
|
||||||
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
|
|
||||||
return new User(user.getUsername(), user.getPassword(), authorities);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue