闭社主体 forked from https://github.com/tootsuite/mastodon
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.

22 lines
727 B

  1. # frozen_string_literal: true
  2. class HomeController < ApplicationController
  3. before_action :authenticate_user!
  4. def index
  5. @body_classes = 'app-body'
  6. @home = Feed.new(:home, current_user.account).get(20)
  7. @mentions = Feed.new(:mentions, current_user.account).get(20)
  8. @token = find_or_create_access_token.token
  9. end
  10. private
  11. def authenticate_user!
  12. redirect_to about_path unless user_signed_in?
  13. end
  14. def find_or_create_access_token
  15. Doorkeeper::AccessToken.find_or_create_for(Doorkeeper::Application.where(superapp: true).first, current_user.id, 'read write follow', Doorkeeper.configuration.access_token_expires_in, Doorkeeper.configuration.refresh_token_enabled?)
  16. end
  17. end