Class: Applications::CreateService

Inherits:
Object
  • Object
show all
Includes:
BaseServiceUtility
Defined in:
app/services/applications/create_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user, params) ⇒ CreateService

Returns a new instance of CreateService.



9
10
11
12
# File 'app/services/applications/create_service.rb', line 9

def initialize(current_user, params)
  @current_user = current_user
  @params = params.except(:ip_address)
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



7
8
9
# File 'app/services/applications/create_service.rb', line 7

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'app/services/applications/create_service.rb', line 7

def params
  @params
end

Instance Method Details

#execute(request) ⇒ Object

EE would override and use ‘request` arg



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/applications/create_service.rb', line 15

def execute(request)
  @application = Doorkeeper::Application.new(params)

  unless params[:scopes].present?
    @application.errors.add(:base, _("Scopes can't be blank"))

    return @application
  end

  @application.save
  notification_service.application_created(current_user)
  @application
end