mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-02 05:38:28 -05:00
Had to add some Devise crud based on advice on their wiki, otherwise you couldn't change your settings without changing your password. Also had to make a hidden field for tos_agreement. I don't really love it but nobody seems to be able to recommend a better way.
25 lines
959 B
Ruby
25 lines
959 B
Ruby
# we need this subclass so that Devise doesn't force people to change their
|
|
# password every time they want to edit their settings. Code copied from
|
|
# https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password
|
|
|
|
class RegistrationsController < Devise::RegistrationsController
|
|
def update
|
|
# required for settings form to submit when password is left blank
|
|
if params[:member][:password].blank?
|
|
params[:member].delete("password")
|
|
params[:member].delete("password_confirmation")
|
|
params[:member].delete("current_password")
|
|
end
|
|
|
|
@member = Member.find(current_member.id)
|
|
if @member.update_attributes(params[:member])
|
|
set_flash_message :notice, :updated
|
|
# Sign in the member bypassing validation in case his password changed
|
|
sign_in @member, :bypass => true
|
|
redirect_to after_update_path_for(@member)
|
|
else
|
|
render "edit"
|
|
end
|
|
end
|
|
end
|