app/controllers/devise/registrations_controller.rb in devise-3.2.4 vs app/controllers/devise/registrations_controller.rb in devise-3.3.0
- old
+ new
@@ -3,19 +3,24 @@
prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy]
# GET /resource/sign_up
def new
build_resource({})
+ @validatable = devise_mapping.validatable?
+ if @validatable
+ @minimum_password_length = resource_class.password_length.min
+ end
respond_with self.resource
end
# POST /resource
def create
build_resource(sign_up_params)
- if resource.save
- yield resource if block_given?
+ resource_saved = resource.save
+ yield resource if block_given?
+ if resource_saved
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
@@ -23,10 +28,14 @@
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
+ @validatable = devise_mapping.validatable?
+ if @validatable
+ @minimum_password_length = resource_class.password_length.min
+ end
respond_with resource
end
end
# GET /resource/edit
@@ -39,12 +48,13 @@
# the current user in place.
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
- if update_resource(resource, account_update_params)
- yield resource if block_given?
+ resource_updated = update_resource(resource, account_update_params)
+ yield resource if block_given?
+ if resource_updated
if is_flashing_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
@@ -108,10 +118,13 @@
end
# The path used after sign up for inactive accounts. You need to overwrite
# this method in your own RegistrationsController.
def after_inactive_sign_up_path_for(resource)
- respond_to?(:root_path) ? root_path : "/"
+ scope = Devise::Mapping.find_scope!(resource)
+ router_name = Devise.mappings[scope].router_name
+ context = router_name ? send(router_name) : self
+ context.respond_to?(:root_path) ? context.root_path : "/"
end
# The default url to be used after updating a resource. You need to overwrite
# this method in your own RegistrationsController.
def after_update_path_for(resource)