I am using spring security plugin in my Grails application and i would like the users registered to login into the application with username or email address provided during the registration process.(just like fb)
I have already looked into the web and concerned Grails docs ::: http://grails-plugins.github.io/grails-spring-security-core/docs/manual/guide/single.html#4.1%20Person%20Class
but could not find any solution.
Any help would be highly appreciated.
Thanks in advance
Spring Boot Login Page tutorial shows how to work with a default login page. Spring security secures all HTTP endpoints by default. A user has to login in a default HTTP form. To enable Spring Boot security, we add spring-boot-starter-security to the dependencies.
As of Spring Security version 5.7. 1, the default username is user and the password is randomly generated and displayed in the console (e.g. 8e557245-73e2-4286-969a-ff57fe326336 ).
From a spring-security point of view, what you should do is implement your own org.springframework.security.core.userdetails.UserDetailsService
public class MyUserServiceImpl implements UserDetailsService{
@Autowired
private AdminUserDao dao;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
... Here comes your logic to get your the user based on email or userid ...
}
}
in your spring config you have to reference your UserDetails class:
<authentication-manager>
<authentication-provider user-service-ref="myUserServiceImpl" />
</authentication-manager>
hth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With