Sha256: 4c4ce77771b28cbd7a22e9cbe84f865fa2d2843a9d10b626d7cc7ee3480da263
Contents?: true
Size: 814 Bytes
Versions: 5
Compression:
Stored size: 814 Bytes
Contents
# frozen_string_literal: true module Devise module Api module ResourceOwnerService class Authenticate < Devise::Api::BaseService option :params, type: Types::Hash option :resource_class, type: Types::Class def call resource = resource_class.find_for_authentication(email: params[:email]) return Failure(error: :invalid_email, record: nil) if resource.blank? return Failure(error: :invalid_authentication, record: resource) unless authenticate!(resource) Success(resource) end private def authenticate!(resource) resource.valid_for_authentication? do resource.valid_password?(params[:password]) end && resource.active_for_authentication? end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems