Class: Ubiquitously::Dzone::User

Inherits:
Base::User show all
Defined in:
lib/ubiquitously/dzone.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

#createObject



22
23
24
# File 'lib/ubiquitously/dzone.rb', line 22

def create
  
end

#loginObject



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

def 
  return true if logged_in?
  
  page = agent.get("http://www.dzone.com/links/loginLightbox.html")
  form = page.form_with(:action => "/links/j_acegi_security_check")
  form["j_username"] = username
  form["j_password"] = password
  page = form.submit
  
  @logged_in = (page.body !~ /Invalid username or password/i).nil?
  
  unless @logged_in
    raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
  end
  
  @logged_in
end