Module: Officepod::Authentication

Included in:
Base
Defined in:
lib/officepod/authentication.rb

Instance Method Summary collapse

Instance Method Details



20
21
22
23
24
# File 'lib/officepod/authentication.rb', line 20

def get_cookie(cookie)
  sid_pattern = /(?!SID=)[a-z0-9]+(?=\;)/
  result = cookie.match sid_pattern
  result.to_s
end

#loginObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/officepod/authentication.rb', line 4

def 
  validates_body
  response = self.class.post(@end_point, @options)
  result = JSON.parse(response.parsed_response)
  cookie = get_cookie(response.headers["set-cookie"])
  result["SID"] = cookie
  result["storage_list"] = storage_auth_list(lang: "ko", cookie: cookie)
  result.delete_if { |k,v| ["result", "resultcode", "message"].include? k }
  result
end

#logoutObject



15
16
17
18
# File 'lib/officepod/authentication.rb', line 15

def logout
  response = self.class.delete(@end_point, @options)
  response.parsed_response
end