1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/lib/devise/strategies/base.rb
2009-10-18 13:25:35 -02:00

24 lines
780 B
Ruby

module Devise
module Strategies
# Base strategy for Devise. Responsible for verifying correct scope and
# mapping.
class Base < Warden::Strategies::Base
# Validate strategy. By default will raise an error if no scope or an
# invalid mapping is found.
def valid?
mapping.for.include?(self.class.name.split("::").last.underscore.to_sym)
end
# Checks if a valid scope was given for devise and find mapping based on
# this scope.
def mapping
@mapping ||= begin
raise "You need to give a scope for Devise authentication" unless scope
raise "You need to give a valid Devise mapping" unless mapping = Devise.mappings[scope]
mapping
end
end
end
end
end