Class: Devise::InvitationsController
- Inherits:
-
DeviseController
- Object
- DeviseController
- Devise::InvitationsController
- Defined in:
- app/controllers/devise/invitations_controller.rb
Instance Method Summary collapse
-
#create {|resource| ... } ⇒ Object
POST /resource/invitation.
-
#destroy ⇒ Object
GET /resource/invitation/remove?invitation_token=abcdef.
-
#edit ⇒ Object
GET /resource/invitation/accept?invitation_token=abcdef.
-
#new ⇒ Object
GET /resource/invitation/new.
-
#update {|resource| ... } ⇒ Object
PUT /resource/invitation.
Instance Method Details
#create {|resource| ... } ⇒ Object
POST /resource/invitation
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/devise/invitations_controller.rb', line 18 def create self.resource = invite_resource resource_invited = resource.errors.empty? yield resource if block_given? if resource_invited if is_flashing_format? && self.resource.invitation_sent_at :notice, :send_instructions, email: self.resource.email end if self.method(:after_invite_path_for).arity == 1 respond_with resource, location: after_invite_path_for(current_inviter) else respond_with resource, location: after_invite_path_for(current_inviter, resource) end else respond_with(resource) end end |
#destroy ⇒ Object
GET /resource/invitation/remove?invitation_token=abcdef
71 72 73 74 75 |
# File 'app/controllers/devise/invitations_controller.rb', line 71 def destroy resource.destroy :notice, :invitation_removed if is_flashing_format? redirect_to after_sign_out_path_for(resource_name) end |
#edit ⇒ Object
GET /resource/invitation/accept?invitation_token=abcdef
39 40 41 42 43 |
# File 'app/controllers/devise/invitations_controller.rb', line 39 def edit set_minimum_password_length resource.invitation_token = params[:invitation_token] render :edit end |
#new ⇒ Object
GET /resource/invitation/new
12 13 14 15 |
# File 'app/controllers/devise/invitations_controller.rb', line 12 def new self.resource = resource_class.new render :new end |
#update {|resource| ... } ⇒ Object
PUT /resource/invitation
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/devise/invitations_controller.rb', line 46 def update raw_invitation_token = update_resource_params[:invitation_token] self.resource = accept_resource invitation_accepted = resource.errors.empty? yield resource if block_given? if invitation_accepted if resource.class.allow_insecure_sign_in_after_accept = resource.active_for_authentication? ? :updated : :updated_not_active :notice, if is_flashing_format? resource.after_database_authentication sign_in(resource_name, resource) respond_with resource, location: after_accept_path_for(resource) else :notice, :updated_not_active if is_flashing_format? respond_with resource, location: new_session_path(resource_name) end else resource.invitation_token = raw_invitation_token respond_with(resource) end end |