Module: Impostor::Phpbb2::Auth
- Defined in:
- lib/impostor/phpbb2.rb
Overview
Additional configuration parameters for a Phpbb2 compatible agent:
:posting_page
Typical configuration parameters { :type => :phpbb2,
:app_root => 'http://example.com/forum/',
:login_page => 'login.php',
:posting_page => 'posting.php',
:user_agent => 'Windows IE 7',
:username => 'myuser',
:password => 'mypasswd' }
Instance Method Summary collapse
-
#get_login_form(page) ⇒ Object
returns the login form from the login page.
-
#logged_in?(page) ⇒ Boolean
Checks if the agent is already logged by stored cookie.
-
#set_username_and_password(form) ⇒ Object
Sets the user name and pass word on the loing form.
Instance Method Details
#get_login_form(page) ⇒ Object
returns the login form from the login page
38 39 40 41 42 |
# File 'lib/impostor/phpbb2.rb', line 38 def get_login_form(page) form = page.forms.detect { |form| form.action =~ /login\.php/ } raise Impostor::LoginError.new("unknown login page format") unless form form end |
#logged_in?(page) ⇒ Boolean
Checks if the agent is already logged by stored cookie
28 29 30 31 32 33 |
# File 'lib/impostor/phpbb2.rb', line 28 def logged_in?(page) mm = page.search( "//a" ).detect{ | a| a.inner_html =~ /Log out \[ #{self.config.username} \]/ } || page.search( "//a" ).detect{ |a| a['href'] =~ /\/login\.php\?mode=logout/ } not mm.nil? end |
#set_username_and_password(form) ⇒ Object
Sets the user name and pass word on the loing form.
47 48 49 50 51 52 53 |
# File 'lib/impostor/phpbb2.rb', line 47 def set_username_and_password(form) form['username'] = self.config.username form['password'] = self.config.password form['autologin'] = 'on' form['login'] = 'Log in' form end |