Skip to content

Commit b8964cb

Browse files
authored
Merge pull request #747 from Iterable/MOB-7795
Remove JWT token generation if user not logged in
2 parents f37b558 + 20d82e5 commit b8964cb

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

swift-sdk/Internal/AuthManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AuthManager: IterableAuthManagerProtocol {
1616
self.dateProvider = dateProvider
1717
self.expirationRefreshPeriod = expirationRefreshPeriod
1818

19-
if self.delegate != nil {
19+
if self.delegate != nil && (localStorage.email != nil || localStorage.userId != nil) {
2020
retrieveAuthToken()
2121
}
2222
}

tests/unit-tests/AuthTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ class AuthTests: XCTestCase {
431431
let localStorage = MockLocalStorage()
432432

433433
localStorage.authToken = mockEncodedPayload
434+
localStorage.userId = AuthTests.userId
434435

435436
let authManager = AuthManager(delegate: authDelegate,
436437
expirationRefreshPeriod: expirationRefreshPeriod,
@@ -457,6 +458,7 @@ class AuthTests: XCTestCase {
457458

458459
let mockLocalStorage = MockLocalStorage()
459460
mockLocalStorage.authToken = mockEncodedPayload
461+
mockLocalStorage.email = AuthTests.email
460462

461463
let authManager = AuthManager(delegate: authDelegate,
462464
expirationRefreshPeriod: expirationRefreshPeriod,

0 commit comments

Comments
 (0)