Sha256: 81f8c0bce88a72cf0c904433dad9db7b28439b7607834bc3ac8344546c353fe2

Contents?: true

Size: 535 Bytes

Versions: 3

Compression:

Stored size: 535 Bytes

Contents

module Spree::Api::BaseController::JsonWebTokens
  def load_user
    return super unless json_web_token.present?
    @current_api_user ||= Spree.user_class.find_by(id: json_web_token['id'])
  end

  def json_web_token
    @json_web_token ||= SolidusJwt.decode(api_key).first
  rescue JWT::DecodeError
    # Allow spree to try and authenticate if we still allow it. Otherwise
    # raise an error
    return if SolidusJwt::Config.allow_spree_api_key
    raise
  end

  def invalid_jwt_format?
    api_key.split('.').size != 3
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_jwt-0.0.2 app/controllers/spree/api/base_controller/json_web_tokens.rb
solidus_jwt-0.0.1 app/controllers/spree/api/base_controller/json_web_tokens.rb
solidus_jwt-0.0.1.pre app/controllers/spree/api/base_controller/json_web_tokens.rb