How to Allow User to Sign in Via Social Login Only in Rails
Recently I need to allow user to register / sign in via Google on a Rails application. Devise was a natural choice and so is the Omniauth for OAuth authentication.
Now user should not be able to sign in or register by any other mechanism which comes with Rails + Devise combo. So I have to disable Sign in and Sign Up feature from the app.
Disable Sign up
When you install and generate Devise specific code, the User model includes a few modules by default to address most of the use cases for sign and sign up.
All you have to do is remove the module registerable from the above configuration. Super simple!
Also, you can remove recoverable and rememberable as well because they don’t make sense if you are going to allow only sign in via social OAuth services. So you will end up with the following configuration.
Disable Sign In
It even simpler. All you need to do is override the path in route.rb
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
Consulting is free – let us help you grow!
Choose Your Language
Subscribe to Our Newsletter
- Digital Marketing
- IT Consulting
- Project Management