Skip to content

Commit

Permalink
Adding better token lifetime management
Browse files Browse the repository at this point in the history
  • Loading branch information
whitslar committed May 17, 2017
1 parent 263c551 commit ea624f2
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 ea624f2

Please sign in to comment.