-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Disables self invite #836
Comments
Sorry, I'm not sure if I understand your suggestion. Do you want to use devise invitable to call invite! class method only from some custom controllers, or model callbacks, so you want to disable new and create actions in invitations controller? I can accept a pull request for that. |
I think another way to do it is defining authenticate_inviter! to raise an exception, redirect or render an error, but if you add that option it could be a cleaner way |
Yeah, the suggested option will disable actions ( |
Do you think adding authenticate_inviter! method to application controller is good enough, or do you want to send pull request? If that's enough, you could improve README or add something to wiki, to help others |
I'll think a bit and return, because at my use case, the invited user needs to be invited by someone which previously sets some parameters and/or relationships. |
I define class Users::InvitationsController < Devise::InvitationsController
private
def invite_resource
super do |new_user|
if new_user == current_user
new_user.errors.add :email, :taken
end
end
end
end |
On the project I'm working on, the users will be only invited after certain operations (e.g. create an user record or invite manually through an authenticated area)
I thought this will be a good addition to the project with a simple option like
self_invite: false
(probably on the model like theinvite_for
, enabling multiple resources using devise to be enable or disable invitations with this new option) and this will disable the route.A workaround I've made is to override the controller using the default devise mechanism and override the new action with a redirect to a root path.
Would you accept a pull request for that?
The text was updated successfully, but these errors were encountered: