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

Happy Coding!

Click here for more details…

At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.

We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.

Consulting is free – let us help you grow!