Sha256: 4768198f19962aeb11a6516c8349483b0208e455431e1f8ce1a6883fe2a15b9a

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module Devise
  module Api
    module TokensService
      class Refresh < Devise::Api::BaseService
        option :devise_api_token, type: Types.Instance(Devise.api.base_token_model.constantize)
        option :resource_owner, default: proc { devise_api_token.resource_owner }

        def call
          return Failure(:expired_refresh_token) if devise_api_token.refresh_token_expired?

          devise_api_token = yield create_devise_api_token
          Success(devise_api_token)
        end

        private

        def create_devise_api_token
          Devise::Api::TokensService::Create.new(resource_owner: resource_owner,
                                                 previous_refresh_token: devise_api_token.refresh_token).call
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise-api-0.1.2 app/services/devise/api/tokens_service/refresh.rb
devise-api-0.1.1 app/services/devise/api/tokens_service/refresh.rb
devise-api-0.1.0 app/services/devise/api/tokens_service/refresh.rb