2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-22 03:57:31 -05:00
|
|
|
module OauthApplications
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
before_action :prepare_scopes, only: [:create, :update]
|
|
|
|
end
|
|
|
|
|
|
|
|
def prepare_scopes
|
2016-12-16 16:59:53 -05:00
|
|
|
scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
|
2016-11-24 02:37:22 -05:00
|
|
|
|
2016-11-22 03:57:31 -05:00
|
|
|
if scopes
|
|
|
|
params[:doorkeeper_application][:scopes] = scopes.join(' ')
|
|
|
|
end
|
|
|
|
end
|
2016-11-24 02:37:22 -05:00
|
|
|
|
|
|
|
def load_scopes
|
2017-09-18 13:25:23 -04:00
|
|
|
@scopes ||= Doorkeeper.configuration.scopes
|
2016-11-24 02:37:22 -05:00
|
|
|
end
|
2021-09-17 11:11:44 -04:00
|
|
|
|
|
|
|
def permitted_params
|
|
|
|
%i{name redirect_uri scopes confidential expire_access_tokens}
|
|
|
|
end
|
|
|
|
|
|
|
|
def application_params
|
|
|
|
params
|
|
|
|
.require(:doorkeeper_application)
|
|
|
|
.permit(*permitted_params)
|
|
|
|
end
|
2016-11-22 03:57:31 -05:00
|
|
|
end
|