Module: Wpxf::ModuleAuthentication
- Included in:
- Module
- Defined in:
- lib/wpxf/core/module_authentication.rb
Overview
Provides functionality for authenticating modules with a WordPress target.
Instance Method Summary collapse
-
#authenticate_with_wordpress(username, password) ⇒ CookieJar, Boolean
Authenticate with WordPress and return the cookie.
-
#initialize ⇒ Object
Initialize a new instance of ModuleAuthentication.
-
#requires_authentication ⇒ Boolean
True if the module requires the user to authenticate.
Instance Method Details
#authenticate_with_wordpress(username, password) ⇒ CookieJar, Boolean
Authenticate with WordPress and return the cookie.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/wpxf/core/module_authentication.rb', line 35 def authenticate_with_wordpress(username, password) emit_info "Authenticating with WordPress using #{username}:#{password}..." = wordpress_login(username, password) if .nil? emit_error 'Failed to authenticate with WordPress' return false else store_credentials username, password emit_success 'Authenticated with WordPress', true return end end |
#initialize ⇒ Object
Initialize a new instance of Wpxf::ModuleAuthentication.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/wpxf/core/module_authentication.rb', line 7 def initialize super return unless requires_authentication ([ StringOption.new( name: 'username', desc: 'The WordPress username to authenticate with', required: true ), StringOption.new( name: 'password', desc: 'The WordPress password to authenticate with', required: true ) ]) end |
#requires_authentication ⇒ Boolean
Returns true if the module requires the user to authenticate.
26 27 28 |
# File 'lib/wpxf/core/module_authentication.rb', line 26 def requires_authentication false end |