Sha256: 81f236a15f66242100c06eb5a8d6c8c480389405d784418a62a774642efd0cd0

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

class Devise::InvitationsController < ApplicationController
  include Devise::Controllers::InternalHelpers

  before_filter :authenticate_inviter!, :only => [:new, :create]
  before_filter :require_no_authentication, :only => [:edit, :update]
  helper_method :after_sign_in_path_for

  # GET /resource/invitation/new
  def new
    build_resource
    render_with_scope :new
  end

  # POST /resource/invitation
  def create
    self.resource = resource_class.invite!(params[resource_name])

    if resource.errors.empty?
      set_flash_message :notice, :send_instructions
      redirect_to after_update_path_for(resource_name)
    else
      render_with_scope :new
    end
  end

  # GET /resource/invitation/accept?invitation_token=abcdef
  def edit
    self.resource = resource_class.new
    resource.invitation_token = params[:invitation_token]
    render_with_scope :edit
  end

  # PUT /resource/invitation
  def update
    self.resource = resource_class.accept_invitation!(params[resource_name])

    if resource.errors.empty?
      set_flash_message :notice, :updated
      sign_in_and_redirect(resource_name, resource)
    else
      render_with_scope :edit
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise_invitable-0.3.7 app/controllers/devise/invitations_controller.rb
devise_invitable-0.3.6 app/controllers/devise/invitations_controller.rb
devise_invitable-0.3.5 app/controllers/devise/invitations_controller.rb
devise_invitable-0.3.4 app/controllers/devise/invitations_controller.rb