Skip to content

Commit

Permalink
Merge pull request #3 from whitslar/master
Browse files Browse the repository at this point in the history
Adding better token lifetime management
  • Loading branch information
salon-lofts-git authored May 17, 2017
2 parents 263c551 + ea624f2 commit 1086c1d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions lib/zimbra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,11 @@ def debug

# Authorization token - obtained after successful login
def auth_token
@@auth_token.token
@@auth_token ||= nil
end

def account_auth_token
@@account_auth_token.token
end

def auth_token_expired?
@@auth_token.expired?
end

def account_auth_token_expired?
@@account_auth_token.expired?
@@account_auth_token ||= nil
end

# Log into the zimbra SOAP service. This is required before any other action is performed
Expand Down
2 changes: 1 addition & 1 deletion lib/zimbra/handsoap_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_create_document(doc)
header = doc.find("Header")
header.add "n1:context" do |s|
s.set_attr "env:mustUnderstand", "0"
s.add "n1:authToken", Zimbra.account_auth_token
s.add "n1:authToken", Zimbra.account_auth_token.token
end
end
def on_response_document(doc)
Expand Down
2 changes: 1 addition & 1 deletion lib/zimbra/handsoap_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def on_create_document(doc)
header = doc.find("Header")
header.add "n1:context" do |s|
s.set_attr "env:mustUnderstand", "0"
s.add "n1:authToken", Zimbra.auth_token
s.add "n1:authToken", Zimbra.auth_token.token
end
end
def on_response_document(doc)
Expand Down

0 comments on commit 1086c1d

Please sign in to comment.