Gab Social. All are welcome.
This commit is contained in:
30
app/controllers/oauth/authorizations_controller.rb
Normal file
30
app/controllers/oauth/authorizations_controller.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
|
||||
skip_before_action :authenticate_resource_owner!
|
||||
|
||||
before_action :store_current_location
|
||||
before_action :authenticate_resource_owner!
|
||||
|
||||
include Localized
|
||||
|
||||
private
|
||||
|
||||
def store_current_location
|
||||
store_location_for(:user, request.url)
|
||||
end
|
||||
|
||||
def render_success
|
||||
if skip_authorization? || (matching_token? && !truthy_param?('force_login'))
|
||||
redirect_or_render authorize_response
|
||||
elsif Doorkeeper.configuration.api_only
|
||||
render json: pre_auth
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def truthy_param?(key)
|
||||
ActiveModel::Type::Boolean.new.cast(params[key])
|
||||
end
|
||||
end
|
||||
26
app/controllers/oauth/authorized_applications_controller.rb
Normal file
26
app/controllers/oauth/authorized_applications_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
|
||||
skip_before_action :authenticate_resource_owner!
|
||||
|
||||
before_action :store_current_location
|
||||
before_action :authenticate_resource_owner!
|
||||
before_action :set_body_classes
|
||||
|
||||
include Localized
|
||||
|
||||
def destroy
|
||||
Web::PushSubscription.unsubscribe_for(params[:id], current_resource_owner)
|
||||
super
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_body_classes
|
||||
@body_classes = 'admin'
|
||||
end
|
||||
|
||||
def store_current_location
|
||||
store_location_for(:user, request.url)
|
||||
end
|
||||
end
|
||||
14
app/controllers/oauth/tokens_controller.rb
Normal file
14
app/controllers/oauth/tokens_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Oauth::TokensController < Doorkeeper::TokensController
|
||||
def revoke
|
||||
unsubscribe_for_token if authorized? && token.accessible?
|
||||
super
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def unsubscribe_for_token
|
||||
Web::PushSubscription.where(access_token_id: token.id).delete_all
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user