Skip to content

Commit

Permalink
Component cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Jan 13, 2024
1 parent 24a81cb commit 998853a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 1 addition & 8 deletions FirebaseAuth/Sources/Swift/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ extension Auth: AuthInterop {
}
}

// This prevents FIRComponentContainer from warning when instantiating from the protocol.
extension Auth: AuthProvider {
func auth() -> Auth {
return self
}
}

/** @class Auth
@brief Manages authentication for Firebase apps.
@remarks This class is thread-safe.
Expand Down Expand Up @@ -175,7 +168,7 @@ extension Auth: AuthProvider {
@return The `Auth` instance associated with the given app.
*/
@objc open class func auth(app: FirebaseApp) -> Auth {
return ComponentType<AuthProvider>.instance(for: AuthProvider.self, in: app.container) as! Auth
return ComponentType<AuthProvider>.instance(for: AuthProvider.self, in: app.container).auth()
}

/** @property app
Expand Down
7 changes: 5 additions & 2 deletions FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ class AuthComponent: NSObject, Library, AuthProvider, ComponentLifecycleMaintain
dependencies: [appCheckInterop]) { container, isCacheable in
guard let app = container.app else { return nil }
isCacheable.pointee = true
return Auth(app: app)
let newComponent = AuthComponent(app: app)
// Set up instances early enough so User on keychain will be decoded.
newComponent.auth()
return newComponent
}]
}

// MARK: - AuthProvider conformance

func auth() -> Auth {
@discardableResult func auth() -> Auth {
os_unfair_lock_lock(&instancesLock)

// Unlock before the function returns.
Expand Down

0 comments on commit 998853a

Please sign in to comment.