1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- class Users::RegistrationsController < Devise::RegistrationsController
-
-
-
- def update
- @user = User.find(current_user.id)
- successfully_updated = if needs_password?(@user, params)
- @user.update_with_password(devise_parameter_sanitizer.sanitize(:account_update))
- else
-
-
- params[:user].delete(:current_password)
- params[:user].delete(:password)
- params[:user].delete(:password_confirmation)
- @user.update_without_password(devise_parameter_sanitizer.sanitize(:account_update))
- end
- if successfully_updated
- set_flash_message :notice, :updated
-
- sign_in @user, :bypass => true
- redirect_to after_update_path_for(@user)
- else
- render "edit"
- end
- end
- def after_sign_up_path_for(resource)
- root_path
- end
-
- private
-
-
-
- def needs_password?(user, params)
- user.email != params[:user][:email] ||
- params[:user][:password].present?
- end
-
- end
|