Sha256: 6cade127e468a1d424d0152bbb1dee7a0fd6a7f735b8c7b459ee4097ee4d054c

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

class Iugu::InvitationsController < Iugu::SettingsController

  before_filter(:only => [:new, :create]) { |c| c.must_be [:owner, :admin], :account_id } 

  def new
    @user_invitation = UserInvitation.new
    @account = Account.find(params[:account_id])
  end

  def create
    params[:user_invitation][:roles] = params[:user_invitation][:roles].try(:join, ',')
    params[:user_invitation][:account_id] = params[:account_id]
    params[:user_invitation][:invited_by] = current_user.id
    @user_invitation = UserInvitation.create(params[:user_invitation])
    unless @user_invitation.new_record?
      redirect_to account_users_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.user_invited")
    else
      @account = Account.find(params[:account_id])
      render :new
    end
  end

  def edit
    if @user_invitation = UserInvitation.find_by_invitation_token(params[:invitation_token])
      @inviter = User.find(@user_invitation.invited_by)
    else
      raise ActionController::RoutingError.new('Not Found')
    end
  end

  def update
    if @user_invitation = UserInvitation.find_by_invitation_token(params[:invitation_token])
      if @user_invitation.accept(current_user)
        redirect_to root_path
      else
        redirect_to root_path, :notice => I18n.t("iugu.notices.you_are_already_member_of_this_account")
      end
    else
      raise ActionController::RoutingError.new('Not Found')
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.21 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.20 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.19 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.18 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.17 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.16 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.14 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.13 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.12 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.11 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.10 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.9 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.7 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.5 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.4 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.3 app/controllers/iugu/invitations_controller.rb
iugusdk-1.0.0.alpha.2 app/controllers/iugu/invitations_controller.rb