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.

29 lines
975 B

  1. # frozen_string_literal: true
  2. class HomeController < ApplicationController
  3. before_action :authenticate_user!
  4. def index
  5. @body_classes = 'app-body'
  6. @token = find_or_create_access_token.token
  7. @web_settings = Web::Setting.find_by(user: current_user)&.data || {}
  8. @admin = Account.find_local(Setting.site_contact_username)
  9. @streaming_api_base_url = Rails.configuration.x.streaming_api_base_url
  10. end
  11. private
  12. def authenticate_user!
  13. redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in?
  14. end
  15. def find_or_create_access_token
  16. Doorkeeper::AccessToken.find_or_create_for(
  17. Doorkeeper::Application.where(superapp: true).first,
  18. current_user.id,
  19. Doorkeeper::OAuth::Scopes.from_string('read write follow'),
  20. Doorkeeper.configuration.access_token_expires_in,
  21. Doorkeeper.configuration.refresh_token_enabled?
  22. )
  23. end
  24. end