This repository has been archived by the owner on Feb 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Had trouble with cancan and forbidden attributes. You can't edit your…
… user info without specifying a "new" password ryanb/cancan#835 , see this for new info on other solutions to the problem.
- Loading branch information
Showing
7 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
class RegistrationsController < Devise::RegistrationsController | ||
before_filter :update_sanitized_params, if: :devise_controller? | ||
|
||
=begin | ||
def update | ||
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) | ||
# custom logic | ||
if params[:user][:password].present? | ||
result = resource.update_with_password(params[resource_name]) | ||
else | ||
puts params[resource_name] | ||
result = resource.update_without_password(params[resource_name]) | ||
end | ||
# standart devise behaviour | ||
if result | ||
if is_navigational_format? | ||
if resource.respond_to?(:pending_reconfirmation?) && resource.pending_reconfirmation? | ||
flash_key = :update_needs_confirmation | ||
end | ||
set_flash_message :notice, flash_key || :updated | ||
end | ||
sign_in resource_name, resource, :bypass => true | ||
respond_with resource, :location => after_update_path_for(resource) | ||
else | ||
clean_up_passwords resource | ||
respond_with resource | ||
end | ||
end | ||
=end | ||
|
||
|
||
def update_sanitized_params | ||
devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)} | ||
devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation, :current_password)} | ||
devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :pseudonym, :email, :password, :password_confirmation)} | ||
devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :pseudonym, :email, :password, :password_confirmation, :current_password)} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters