11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/contacts/gmail.rb', line 11
def real_connect
postdata = "ltmpl=yj_blanco"
postdata += "&continue=%s" % CGI.escape(URL)
postdata += "<mplcache=2"
postdata += "&service=mail"
postdata += "&rm=false"
postdata += "<mpl=yj_blanco"
postdata += "&hl=en"
postdata += "&Email=%s" % CGI.escape(login)
postdata += "&Passwd=%s" % CGI.escape(password)
postdata += "&rmShown=1"
postdata += "&null=Sign+in"
time = Time.now.to_i
time_past = Time.now.to_i - 8 - rand(12)
cookie = "GMAIL_LOGIN=T#{time_past}/#{time_past}/#{time}"
data, resp, cookies, forward, old_url = post(LOGIN_URL, postdata, cookie, LOGIN_REFERER_URL) + [LOGIN_URL]
cookies = remove_cookie("GMAIL_LOGIN", cookies)
if data.index("The username or password you entered is incorrect")
raise AuthenticationError, "Username and password do not match"
elsif data.index("We cannot log you into your account at this time") || data.index("Required field cannot be left blank")
raise AuthenticationError, "Login and password must not be blank"
elsif data.index("errormsg_0_logincaptcha")
raise AuthenticationError, "Captcha error"
elsif data.index("Invalid request")
raise ConnectionError, PROTOCOL_ERROR
elsif cookies == ""
raise ConnectionError, PROTOCOL_ERROR
end
cookies = remove_cookie("LSID", cookies)
cookies = remove_cookie("GV", cookies)
@cookies = cookies
end
|