Class: Ubiquitously::Propeller::User

Inherits:
Base::User show all
Defined in:
lib/ubiquitously/propeller.rb

Instance Attribute Summary

Attributes inherited from Base::User

#agent, #password, #username

Instance Method Summary collapse

Methods inherited from Base::User

#initialize, #logged_in?

Methods included from Resourceful

included

Constructor Details

This class inherits a constructor from Ubiquitously::Base::User

Instance Method Details

#loginObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ubiquitously/propeller.rb', line 4

def 
  puts "LOGGING IN"
  page = agent.get("http://www.propeller.com/signin/")
  form = page.forms.detect {|form| form.form_node["class"] == "ajax-form"}
  form["member_name"] = username
  form["password"]    = password
  form["submit"]      = "sign in" # require to get around the ajax
  page                = form.submit
  puts "DONE"
  @logged_in = (page.body =~ /Invalid member name or password/i).nil? && (page.body =~ /ajax-form/).nil?
  
  unless @logged_in
    raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
  end
  
  @logged_in
end