Permalink
Browse files

0.3.21

  • Loading branch information...
1 parent afa2262 commit 67c8aabb5ebd7ceb31be50fb40dafbe51444a133 @dsaronin committed Dec 10, 2011
Showing with 32 additions and 3 deletions.
  1. +32 −3 app/controllers/registrations_controller.rb
View
35 app/controllers/registrations_controller.rb
@@ -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
@@ -61,6 +59,37 @@ def sign_out_session!()
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
+
+# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
end # class Registrations

0 comments on commit 67c8aab

Please sign in to comment.