Class: Doorkeeper::DeviceAuthorizationGrant::DeviceAuthorizationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/doorkeeper/device_authorization_grant/device_authorizations_controller.rb

Overview

The Device Authorizations controller provides a simple interface which allows authenticated resource owners to authorize devices, by providing a user code.

Instance Method Summary collapse

Instance Method Details

#authorizeObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/doorkeeper/device_authorization_grant/device_authorizations_controller.rb', line 18

def authorize
  device_grant_model.transaction do
    device_grant = device_grant_model.lock.find_by(user_code: user_code)
    next authorization_error_response(:invalid_user_code) if device_grant.nil?
    next authorization_error_response(:expired_user_code) if device_grant.expired?

    device_grant.update!(user_code: nil, resource_owner_id: current_resource_owner.id)

    authorization_success_response
  end
end

#indexObject



11
12
13
14
15
16
# File 'app/controllers/doorkeeper/device_authorization_grant/device_authorizations_controller.rb', line 11

def index
  respond_to do |format|
    format.html
    format.json { head :no_content }
  end
end