Sha256: 366f6087344ccc86f9002e303f63f17232681b6fcc07e4be182ef6b8a12c1692

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

module Milia

  class RegistrationsController < Devise::RegistrationsController

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
# create -- intercept the POST create action upon new sign-up
# new tenant account is vetted, then created, then proceed with devise create user
# CALLBACK: Tenant.create_new_tenant  -- prior to completing user account
# CALLBACK: Tenant.tenant_signup      -- after completing user account
# ------------------------------------------------------------------------------
    def create
      
      sign_out_session!

      @tenant = Tenant.create_new_tenant(params)
      if @tenant.errors.empty?   # tenant created
        
        initiate_tenant( @tenant )    # first time stuff for new tenant
        super   # devise resource(user) creation; sets resource

        puts "************* resource is: #{resource.inspect} ***************"
        
        Tenant.tenant_signup(resource, @tenant,params[:coupon])
      
      else
        @user = User.new(params[:user])
        render :action => 'new'
      end
            
    end   # def create

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
  private
# ------------------------------------------------------------------------------
# sign_out_session! -- force the devise session signout
# ------------------------------------------------------------------------------

    def sign_out_session!()
      Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) if user_signed_in?
    end

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

  end   # class Registrations

end  # module Milia

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milia-0.3.11 app/controllers/registrations_controller.rb
milia-0.3.10 app/controllers/registrations_controller.rb
milia-0.3.9 app/controllers/registrations_controller.rb