class Devise::RegistrationsController
def account_update_params
def account_update_params devise_parameter_sanitizer.sanitize(:account_update) end
def after_inactive_sign_up_path_for(resource)
The path used after sign up for inactive accounts. You need to overwrite
def after_inactive_sign_up_path_for(resource) 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
def after_sign_up_path_for(resource)
The path used after sign up. You need to overwrite this method
def after_sign_up_path_for(resource) after_sign_in_path_for(resource) if is_navigational_format? end
def after_update_path_for(resource)
The default url to be used after updating a resource. You need to overwrite
def after_update_path_for(resource) sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name) end
def authenticate_scope!
def authenticate_scope! send(:"authenticate_#{resource_name}!", force: true) self.resource = send(:"current_#{resource_name}") end
def build_resource(hash = {})
Build a devise resource passing in the session. Useful to move
def build_resource(hash = {}) self.resource = resource_class.new_with_session(hash, session) end
def cancel
cancel oauth signing in/up in the middle of the process,
in to be expired now. This is useful if the user wants to
Forces the session data which is usually expired after sign
GET /resource/cancel
def cancel expire_data_after_sign_in! redirect_to new_registration_path(resource_name) end
def create
def create build_resource(sign_up_params) resource.save yield resource if block_given? if resource.persisted? if resource.active_for_authentication? set_flash_message! :notice, :signed_up sign_up(resource_name, resource) respond_with resource, location: after_sign_up_path_for(resource) else set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}" expire_data_after_sign_in! respond_with resource, location: after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource set_minimum_password_length respond_with resource end end
def destroy
def destroy resource.destroy Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) set_flash_message! :notice, :destroyed yield resource if block_given? respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status } end
def edit
def edit render :edit end
def new
def new build_resource yield resource if block_given? respond_with resource end
def set_flash_message_for_update(resource, prev_unconfirmed_email)
def set_flash_message_for_update(resource, prev_unconfirmed_email) return unless is_flashing_format? flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email) :update_needs_confirmation elsif sign_in_after_change_password? :updated else :updated_but_not_signed_in end set_flash_message :notice, flash_key end
def sign_in_after_change_password?
def sign_in_after_change_password? return true if account_update_params[:password].blank? Devise.sign_in_after_change_password end
def sign_up(resource_name, resource)
Signs in a user on sign up. You can overwrite this method in your own
def sign_up(resource_name, resource) sign_in(resource_name, resource) end
def sign_up_params
def sign_up_params devise_parameter_sanitizer.sanitize(:sign_up) end
def translation_scope
def translation_scope 'devise.registrations' end
def update
We need to use a copy of the resource because we don't want to change
PUT /resource
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) resource_updated = update_resource(resource, account_update_params) yield resource if block_given? if resource_updated set_flash_message_for_update(resource, prev_unconfirmed_email) bypass_sign_in resource, scope: resource_name if sign_in_after_change_password? respond_with resource, location: after_update_path_for(resource) else clean_up_passwords resource set_minimum_password_length respond_with resource end end
def update_needs_confirmation?(resource, previous)
def update_needs_confirmation?(resource, previous) resource.respond_to?(:pending_reconfirmation?) && resource.pending_reconfirmation? && previous != resource.unconfirmed_email end
def update_resource(resource, params)
By default we want to require a password checks on update.
def update_resource(resource, params) resource.update_with_password(params) end