2 extend ActiveSupport::Concern
7 # update a user's details
8 def update_user(user, params)
9 user.display_name = params[:user][:display_name]
10 user.new_email = params[:user][:new_email]
12 unless params[:user][:pass_crypt].empty? && params[:user][:pass_crypt_confirmation].empty?
13 user.pass_crypt = params[:user][:pass_crypt]
14 user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
17 if params[:user][:auth_provider].nil? || params[:user][:auth_provider].blank?
18 user.auth_provider = nil
23 session[:fingerprint] = user.fingerprint
25 if user.new_email.blank? || user.new_email == user.email
26 flash[:notice] = t "accounts.update.success"
28 user.email = user.new_email
31 flash[:notice] = t "accounts.update.success_confirm_needed"
34 UserMailer.email_confirm(user, user.tokens.create).deliver_later
36 # Ignore errors sending email
39 current_user.errors.add(:new_email, current_user.errors[:email])
40 current_user.errors.add(:email, [])