Class: Autumn::Authentication::Base
- Inherits:
-
Object
- Object
- Autumn::Authentication::Base
- Defined in:
- lib/autumn/authentication.rb
Overview
The basic subclass for all authenticators. If you wish to write your own authenticator, you must subclass this class. You must at a minimum override the authenticate method. You should also override the initialize method if you need to store any options or other data for later use.
The authentication module will become a stem listener, so see Autumn::Stem#add_listener for information on other methods you can implement.
Instance Method Summary collapse
-
#authenticate(stem, channel, sender, leaf) ⇒ Object
Returns true if the user is authorized, false if not.
-
#initialize(options = {}) ⇒ Base
constructor
Stores the options for this authenticator and configures it for use.
-
#unauthorized ⇒ Object
Returns a string to be displayed to a user who is not authorized to perform a command.
Constructor Details
#initialize(options = {}) ⇒ Base
Stores the options for this authenticator and configures it for use.
42 43 44 |
# File 'lib/autumn/authentication.rb', line 42 def initialize(={}) raise "You can only instantiate subclasses of this class." end |
Instance Method Details
#authenticate(stem, channel, sender, leaf) ⇒ Object
Returns true if the user is authorized, false if not. sender
is a sender hash as defined in the Autumn::Stem docs.
49 50 51 |
# File 'lib/autumn/authentication.rb', line 49 def authenticate(stem, channel, sender, leaf) raise "Subclasses must override the Autumn::Authentication::Base#authenticate method." end |
#unauthorized ⇒ Object
Returns a string to be displayed to a user who is not authorized to perform a command. Override this method to provide more specific hints to a user on what he can do to authorize himself (e.g., “Tell me your password”).
58 59 60 |
# File 'lib/autumn/authentication.rb', line 58 def "You must be an administrator for this bot to do that." end |