Class: Spree::Api::V2::Storefront::UserRegistrationWithPinCodesController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/storefront/user_registration_with_pin_codes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/spree/api/v2/storefront/user_registration_with_pin_codes_controller.rb', line 12

def create
  options = user_with_pin_code_params
  context = SpreeCmCommissioner::UserPinCodeAuthenticator.call(options)

  if context.success?

    token_context = SpreeCmCommissioner::OauthTokenGenerator.call(
      application: doorkeeper_token.application,
      resource_owner: context.user
    )

    render json: token_context.token_response
  else
    render_error_payload(context.message)
  end
end

#validate_token_client!Object

Raises:

  • (Doorkeeper::Errors::DoorkeeperError)


8
9
10
# File 'app/controllers/spree/api/v2/storefront/user_registration_with_pin_codes_controller.rb', line 8

def validate_token_client!
  raise Doorkeeper::Errors::DoorkeeperError if doorkeeper_token&.application.nil?
end