Module: Impostor::Phpbb3::Auth

Defined in:
lib/impostor/phpbb3.rb

Overview

Additional configuration parameters for a Phpbb3 compatible agent:

:posting_page

Typical configuration parameters { :type => :phpbb3,

:app_root => 'http://example.com/forum/',
:login_page => 'ucp.php?mode=login',
:posting_page => 'posting.php',
:user_agent => 'Windows IE 7',
:username => 'myuser',
:password => 'mypasswd' }

Instance Method Summary collapse

Instance Method Details

#get_login_form(page) ⇒ Object

returns the login form from the login page



38
39
40
41
42
# File 'lib/impostor/phpbb3.rb', line 38

def (page)
  form = page.forms.detect { |form| form.action =~ /\/ucp\.php\?mode=login/ }
  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

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'lib/impostor/phpbb3.rb', line 28

def logged_in?(page)
  mm = page.search( "//a" ).detect{ | a| a.inner_html =~ /Logout \[ #{self.config.username} \]/ } ||
       page.search( "//a" ).detect{ |a| a['href'] =~ /\.\/ucp\.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/phpbb3.rb', line 47

def set_username_and_password(form)
  form['username'] = self.config.username
  form['password'] = self.config.password
  form['login'] = 'Login'
  form['autologin'] = 'on'
  form
end