Skip to content

Commit

Permalink
resume() fix for expired login tokens;
Browse files Browse the repository at this point in the history
  • Loading branch information
yvdorofeev committed May 7, 2017
1 parent 420eeb9 commit 0c0f0da
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions SwiftDDP/DDPExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,21 @@ extension DDPClient {
public func resume(_ url:String, callback:DDPCallback?) {
connect(url) { session in
if let _ = self.user() {
self.loginWithToken() { result, error in
if let error = error {
if !self.loginWithToken() { result, error in
if error == nil {
log.debug("Resumed previous session at launch")
if let completion = callback { completion() }
} else {
self.logout()
log.error("\(error)")
} else {
log.debug("Resumed previous session at launch")
callback?()
}
}{
self.logout()
callback?()
}
} else {
callback?()
if let completion = callback { completion() }
}
}
}
Expand Down

0 comments on commit 0c0f0da

Please sign in to comment.