2 extend ActiveSupport::Concern
7 # update a user's details
8 def update_user(user, params)
9 user.display_name = params[:display_name]
10 user.new_email = params[:new_email]
12 unless params[:pass_crypt].empty? && params[:pass_crypt_confirmation].empty?
13 user.pass_crypt = params[:pass_crypt]
14 user.pass_crypt_confirmation = params[:pass_crypt_confirmation]
17 if params[:auth_provider].nil? || params[: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, [])