module Public class AccountsController < WebBaseController before_action :require_login! def show end def update name = params[:name].to_s.strip if name.blank? flash.now[:alert] = t("flash.accounts.name_required") return render :show, status: :unprocessable_entity end if current_user.update(name: name) redirect_to public_account_path, notice: t("flash.accounts.profile_updated") else flash.now[:alert] = current_user.errors.full_messages.to_sentence render :show, status: :unprocessable_entity end end def update_password result = Users::ChangePassword.call( user: current_user, current_password: params[:current_password], password: params[:password], password_confirmation: params[:password_confirmation] ) unless result.ok? redirect_to public_account_path, alert: t("flash.accounts.password_#{result.error}") return end redirect_to public_account_path, notice: t("flash.accounts.password_updated") end end end