Sha256: ccc60907aa16f4b2b5512c580c6315121f59acfeed4b312d27e91db5df096849

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Devise
  module Strategies
    class Ott < Devise::Strategies::Authenticatable
      def valid?
        super || valid_for_ott_auth?
      end

      def authenticate!
        ott_token = params[:ott_token]

        return fail! unless mapping.to.respond_to?(:find_for_ott_authentication) # Dont try to authenticate if module is not included

        resource = mapping.to.find_for_ott_authentication(ott_token)

        return fail! unless resource

        if validate(resource){ resource.ott_allowed?(ott_token, resource.email) }
          success!(resource)
        end
      end

      private
      # Ott Authenticatable can be authenticated with params in any controller and any verb.
      def valid_params_request?
        true
      end

      # Do not use remember_me behavior with ott token.
      def remember_me?
        false
      end

      # Check if this is strategy is valid for ott authentication by:
      #
      #   * If the ott token exists;
      #
      def valid_for_ott_auth?
        params[:ott_token].present?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_ott-0.0.1 lib/devise/strategies/ott.rb