lib/lastpass/fetcher.rb in lastpass-1.3.0 vs lib/lastpass/fetcher.rb in lastpass-1.4.0
- old
+ new
@@ -1,15 +1,22 @@
# Copyright (C) 2013 Dmitry Yakimenko (detunized@gmail.com).
# Licensed under the terms of the MIT license. See LICENCE for details.
module LastPass
class Fetcher
- def self.login username, password, multifactor_password = nil
+ def self.login username, password, multifactor_password = nil, client_id = nil
key_iteration_count = request_iteration_count username
- request_login username, password, key_iteration_count, multifactor_password
+ request_login username, password, key_iteration_count, multifactor_password, client_id
end
+ def self.logout session, web_client = http
+ response = web_client.get "https://lastpass.com/logout.php?mobile=1",
+ cookies: {"PHPSESSID" => URI.encode(session.id)}
+
+ raise NetworkError unless response.response.is_a? Net::HTTPOK
+ end
+
def self.fetch session, web_client = http
response = web_client.get "https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android",
format: :plain,
cookies: {"PHPSESSID" => URI.encode(session.id)}
@@ -37,10 +44,11 @@
def self.request_login username,
password,
key_iteration_count,
multifactor_password = nil,
+ client_id = nil,
web_client = http
body = {
method: "mobile",
web: 1,
@@ -49,9 +57,10 @@
hash: make_hash(username, password, key_iteration_count),
iterations: key_iteration_count
}
body[:otp] = multifactor_password if multifactor_password
+ body[:imei] = client_id if client_id
response = web_client.post "https://lastpass.com/login.php",
format: :xml,
body: body