You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
981 B

  1. # frozen_string_literal: true
  2. class Settings::ProfilesController < ApplicationController
  3. layout 'auth'
  4. before_action :authenticate_user!
  5. before_action :set_account
  6. def show
  7. end
  8. def update
  9. if @account.update(account_params)
  10. redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
  11. else
  12. render action: :show
  13. end
  14. end
  15. private
  16. def account_params
  17. p = params.require(:account).permit(:display_name, :note, :avatar, :header, :silenced)
  18. if p[:avatar]
  19. avatar = p[:avatar]
  20. # Change so Paperclip won't expose the actual filename
  21. avatar.original_filename = "media" + File.extname(avatar.original_filename)
  22. end
  23. if p[:header]
  24. header = p[:header]
  25. # Change so Paperclip won't expose the actual filename
  26. header.original_filename = "media" + File.extname(header.original_filename)
  27. end
  28. p
  29. end
  30. def set_account
  31. @account = current_user.account
  32. end
  33. end