Class: Spree::Api::OauthsController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/controllers/api/spree/api/oauths_controller.rb

Instance Method Summary collapse

Instance Method Details

#tokenObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/controllers/api/spree/api/oauths_controller.rb', line 8

def token
  result = catch(:warden) do
    try_authenticate_user
  end

  case result
  when Spree::User
    render json: token_response_json(result)
  when Hash
    render status: :unauthorized, json: { error: I18n.t(result[:message], scope: 'devise.failure') }
  else
    render status: :unauthorized, json: { error: I18n.t(:invalid_credentials, scope: 'solidus_jwt') }
  end
end