Reputation: 4097
I have created an Admin model with Devise.
Now I want create a User model (with Devise) and the user must be capable of password recovery, edit the profile and sign in but not able to sign_up.
The sign up for the User is only available to Admins.
If I generate the Devise User Model with the registerable module, how can I have the sign up page so that it is only available to admins and not to the user?
Thanks for your support
Upvotes: 1
Views: 81
Reputation: 1567
If you have app/controllers/registrations_controller.rb add:
before_filter :authenticate_admin!
Otherwise, you will have to show some of the code you are using.
Upvotes: 1
Reputation: 2205
Devise gives you the helper method authenticate_resource! where resource is your model. In this case you would have authenticate_user! and authenticate_admin! You could put in your register controller something like:
before_filter :authenticate_admin!
skip_before_filter :authenticate_user!
The first part would make sure that the admin is the only one allowed, no one else. The second part makes sure that the admin doesn't also have to somehow be a user.
Upvotes: 1