Skip to content

Commit

Permalink
0.3.21
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaronin committed Dec 10, 2011
1 parent afa2262 commit 67c8aab
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ def create

initiate_tenant( @tenant ) # first time stuff for new tenant

super # devise resource(user) creation; sets resource
devise_create # devise resource(user) creation; sets resource

if resource.errors.empty?
Tenant.tenant_signup(resource, @tenant, params[:coupon])
else # user creation failed; force tenant rollback
prep_signup_view( @tenant, resource )
render :new
raise ActiveRecord::Rollback # force the tenant transaction to be rolled back
end # if..then..else for valid user creation

Expand Down Expand Up @@ -60,6 +58,37 @@ def sign_out_session!()
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) if user_signed_in?
end

# ------------------------------------------------------------------------------
# devise_create -- duplicate of Devise::RegistrationsController
# same as in devise gem EXCEPT need to prep signup form variables
# ------------------------------------------------------------------------------
def devise_create
build_resource

if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else # resource had errors ...
prep_devise_new_view( @tenant, resource )
end
end

# ------------------------------------------------------------------------------
# prep_devise_new_view -- common code to prep for another go at the signup form
# ------------------------------------------------------------------------------
def prep_devise_new_view( tenant, resource )
clean_up_passwords(resource)
prep_signup_view( tenant, resource ) # PUNDA special addition
respond_with_navigational(resource) { render_with_scope :new }
end

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

Expand Down

0 comments on commit 67c8aab

Please sign in to comment.