Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion FirebaseAuth/Sources/Swift/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,16 @@ extension Auth: AuthInterop {
private let keychainServices: AuthKeychainServices

/// The user access (ID) token used last time for posting auth state changed notification.
private var lastNotifiedUserToken: String?
///
/// - Note: The atomic wrapper can be removed when the SDK is fully
/// synchronized with structured concurrency.
private var lastNotifiedUserToken: String? {
get { lastNotifiedUserTokenLock.withLock { _lastNotifiedUserToken } }
set { lastNotifiedUserTokenLock.withLock { _lastNotifiedUserToken = newValue } }
}

private var _lastNotifiedUserToken: String?
private var lastNotifiedUserTokenLock = NSLock()

/// This flag denotes whether or not tokens should be automatically refreshed.
/// Will only be set to `true` if the another Firebase service is included (additionally to
Expand Down
15 changes: 12 additions & 3 deletions FirebaseAuth/Sources/Swift/SystemService/SecureTokenService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,17 @@ class SecureTokenService: NSObject, NSSecureCoding {
///
/// This method is specifically for providing the access token to internal clients during
/// deserialization and sign-in events, and should not be used to retrieve the access token by
/// anyone else.
var accessToken: String
/// anyone else.
///
/// - Note: The atomic wrapper can be removed when the SDK is fully
/// synchronized with structured concurrency.
var accessToken: String {
get { accessTokenLock.withLock { _accessToken } }
set { accessTokenLock.withLock { _accessToken = newValue } }
}

private var _accessToken: String
private let accessTokenLock = NSLock()

/// The refresh token for the user, or `nil` if the user has yet completed sign-in flow.
///
Expand All @@ -147,7 +156,7 @@ class SecureTokenService: NSObject, NSSecureCoding {
refreshToken: String) {
internalService = SecureTokenServiceInternal()
self.requestConfiguration = requestConfiguration
self.accessToken = accessToken
_accessToken = accessToken
self.accessTokenExpirationDate = accessTokenExpirationDate
self.refreshToken = refreshToken
}
Expand Down
Loading