Sha256: 3a1dc0fb616d47e0093749e28bc0408dae73e56bcd8c7c93d7cd0a575dc82245

Contents?: true

Size: 987 Bytes

Versions: 5

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

module Devise
  module Api
    module ResourceOwnerService
      class SignIn < Devise::Api::BaseService
        option :params, type: Types::Hash
        option :resource_class, type: Types::Class

        def call
          resource_owner = yield call_authenticate_service
          devise_api_token = yield call_create_devise_api_token_service(resource_owner)
          resource_owner.reset_failed_attempts! if resource_owner.class.supported_devise_modules.lockable?

          Success(devise_api_token)
        end

        private

        def call_authenticate_service
          Devise::Api::ResourceOwnerService::Authenticate.new(params: params,
                                                              resource_class: resource_class).call
        end

        def call_create_devise_api_token_service(resource_owner)
          Devise::Api::TokensService::Create.new(resource_owner: resource_owner).call
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise-api-0.2.0 app/services/devise/api/resource_owner_service/sign_in.rb
devise-api-0.1.3 app/services/devise/api/resource_owner_service/sign_in.rb
devise-api-0.1.2 app/services/devise/api/resource_owner_service/sign_in.rb
devise-api-0.1.1 app/services/devise/api/resource_owner_service/sign_in.rb
devise-api-0.1.0 app/services/devise/api/resource_owner_service/sign_in.rb