def authenticate_session session_params, field_map = nil
      token_field = Oath.config.user_token_field
      params_hash = Oath.transform_params(session_params).symbolize_keys
      password = params_hash.fetch(token_field)
      user = Oath.lookup(params_hash.except(token_field), field_map)
      authenticate(user, password)
    end
def authenticate_session session_params, field_map = nil
      token_field = Oath.config.user_token_field
      params_hash = Oath.transform_params(session_params).symbolize_keys
      password = params_hash.fetch(token_field)
      user = Oath.lookup(params_hash.except(token_field), field_map)
      authenticate(user, password)
    end
Authenticates a session.

 @note Uses the {Oath::Services::Authentication} service to verify the user's details

 @param session_params [Hash] params containing lookup and token fields
 @param field_map [Hash] Field map used for allowing users to sign in with multiple fields e.g. email and username
 @return [User] if authentication succeeded
 @return [nil] if authentication failed
 @example Basic usage
   class SessionsController < ApplicationController
     def create
       user = authenticate_session(session_params)

        if sign_in(user)
          redirect_to(root_path)
        else
          render :new
        end
      end

      private

      def session_params
        params.require(:session).permit(:email, :password)
      end

    end
 @example Using the field map to authenticate using multiple lookup fields
   class SessionsController < ApplicationController
     def create
       user = authenticate_session(session_params, email_or_username: [:email, :username])

        if sign_in(user)
          redirect_to(root_path)
        else
          render :new
        end
      end

      private

      def session_params
        params.require(:session).permit(:email_or_username, :password)
      end

    end