debian-mirror-gitlab/app/controllers/concerns/oauth_applications.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
824 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module OauthApplications
extend ActiveSupport::Concern
2021-12-11 22:18:48 +05:30
CREATED_SESSION_KEY = :oauth_applications_created
2017-08-17 22:00:37 +05:30
included do
before_action :prepare_scopes, only: [:create, :update]
end
def prepare_scopes
scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
2023-03-04 22:38:38 +05:30
params[:doorkeeper_application][:scopes] = scopes.join(' ') if scopes
2017-08-17 22:00:37 +05:30
end
2021-12-11 22:18:48 +05:30
def set_created_session
session[CREATED_SESSION_KEY] = true
end
def get_created_session
session.delete(CREATED_SESSION_KEY) || false
end
2017-08-17 22:00:37 +05:30
def load_scopes
2018-03-17 18:26:18 +05:30
@scopes ||= Doorkeeper.configuration.scopes
2017-08-17 22:00:37 +05:30
end
2021-11-11 11:23:49 +05:30
def permitted_params
2023-03-04 22:38:38 +05:30
%i[name redirect_uri scopes confidential]
2021-11-11 11:23:49 +05:30
end
def application_params
params
.require(:doorkeeper_application)
.permit(*permitted_params)
end
2017-08-17 22:00:37 +05:30
end