1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
This commit is contained in:
Emelia Smith 2024-07-31 14:07:13 +00:00 committed by GitHub
commit 5498c9652b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 5 deletions

View file

@ -19,6 +19,14 @@ module ApplicationExtension
before_destroy :close_streaming_sessions, prepend: true before_destroy :close_streaming_sessions, prepend: true
end end
class_methods do
def webapp
Doorkeeper::Application.find_by!(name: 'Web', superapp: true)
rescue ActiveRecord::RecordNotFound
Doorkeeper::Application.create!(name: 'Web', redirect_uri: Doorkeeper.configuration.native_redirect_uri, scopes: 'read write follow push', superapp: true)
end
end
def confirmation_redirect_uri def confirmation_redirect_uri
redirect_uri.lines.first.strip redirect_uri.lines.first.strip
end end

View file

@ -62,9 +62,9 @@ class SessionActivation < ApplicationRecord
def access_token_attributes def access_token_attributes
{ {
application_id: Doorkeeper::Application.find_by(superapp: true)&.id, application_id: Doorkeeper::Application.webapp.id,
resource_owner_id: user_id, resource_owner_id: user_id,
scopes: 'read write follow', scopes: Doorkeeper::Application.webapp.scopes.without('push'),
expires_in: Doorkeeper.configuration.access_token_expires_in, expires_in: Doorkeeper.configuration.access_token_expires_in,
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?, use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?,
} }

View file

@ -84,9 +84,9 @@ class Web::PushSubscription < ApplicationRecord
def find_or_create_access_token def find_or_create_access_token
Doorkeeper::AccessToken.find_or_create_for( Doorkeeper::AccessToken.find_or_create_for(
application: Doorkeeper::Application.find_by(superapp: true), application: Doorkeeper::Application.webapp,
resource_owner: user_id || session_activation.user_id, resource_owner: user_id || session_activation.user_id,
scopes: Doorkeeper::OAuth::Scopes.from_string('read write follow push'), scopes: Doorkeeper::Application.webapp.scopes,
expires_in: Doorkeeper.configuration.access_token_expires_in, expires_in: Doorkeeper.configuration.access_token_expires_in,
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled? use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?
) )

View file

@ -1,3 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
Doorkeeper::Application.create_with(name: 'Web', redirect_uri: Doorkeeper.configuration.native_redirect_uri, scopes: 'read write follow push').find_or_create_by(superapp: true) Doorkeeper::Application.webapp