2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-24 02:38:06 -04:00
|
|
|
module Applications
|
|
|
|
class CreateService
|
2019-02-06 07:41:17 -05:00
|
|
|
attr_reader :current_user, :params
|
|
|
|
|
2017-10-24 02:38:06 -04:00
|
|
|
def initialize(current_user, params)
|
|
|
|
@current_user = current_user
|
2019-09-18 10:02:45 -04:00
|
|
|
@params = params.except(:ip_address)
|
2017-10-24 02:38:06 -04:00
|
|
|
end
|
|
|
|
|
2018-10-09 23:47:27 -04:00
|
|
|
# EE would override and use `request` arg
|
2018-06-07 07:22:29 -04:00
|
|
|
def execute(request)
|
2020-09-02 11:10:54 -04:00
|
|
|
@application = Doorkeeper::Application.new(params)
|
|
|
|
|
|
|
|
unless params[:scopes].present?
|
|
|
|
@application.errors.add(:base, _("Scopes can't be blank"))
|
|
|
|
|
|
|
|
return @application
|
|
|
|
end
|
|
|
|
|
|
|
|
@application.save
|
|
|
|
@application
|
2017-10-24 02:38:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Applications::CreateService.prepend_mod_with('Applications::CreateService')
|