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
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ protocol AppleOperationReauthentication {
}

extension AppleOperationReauthentication {
@MainActor func reauthenticate() async throws -> AuthenticationToken {
@MainActor func reauthenticate() async throws {
guard let user = Auth.auth().currentUser else {
throw AuthServiceError.reauthenticationRequired("No user currently signed-in")
}

do {
let credential = try await appleProvider.createAuthCredential()
try await user.reauthenticate(with: credential)

return .firebase("")
} catch {
throw AuthServiceError.signInFailed(underlying: error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protocol EmailPasswordOperationReauthentication {

extension EmailPasswordOperationReauthentication {
// TODO: - @MainActor because User is non-sendable. Might change this once User is sendable in firebase-ios-sdk
@MainActor func reauthenticate() async throws -> AuthenticationToken {
@MainActor func reauthenticate() async throws {
guard let user = Auth.auth().currentUser else {
throw AuthServiceError.reauthenticationRequired("No user currently signed-in")
}
Expand All @@ -35,8 +35,6 @@ extension EmailPasswordOperationReauthentication {

let credential = EmailAuthProvider.credential(withEmail: email, password: password)
try await Auth.auth().currentUser?.reauthenticate(with: credential)

return .firebase("")
} catch {
throw AuthServiceError.signInFailed(underlying: error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ extension NSError {
}
}

public enum AuthenticationToken {
case apple(ASAuthorizationAppleIDCredential, String)
case firebase(String)
}

@MainActor
public protocol AuthenticatedOperation {
func callAsFunction(on user: User) async throws
func reauthenticate() async throws -> AuthenticationToken
func reauthenticate() async throws
}

public extension AuthenticatedOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ protocol FacebookOperationReauthentication {
}

extension FacebookOperationReauthentication {
@MainActor func reauthenticate() async throws -> AuthenticationToken {
@MainActor func reauthenticate() async throws {
guard let user = Auth.auth().currentUser else {
throw AuthServiceError.reauthenticationRequired("No user currently signed-in")
}

do {
let credential = try await facebookProvider.createAuthCredential()
try await user.reauthenticate(with: credential)

return .firebase("")
} catch {
throw AuthServiceError.signInFailed(underlying: error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protocol GoogleOperationReauthentication {
}

extension GoogleOperationReauthentication {
@MainActor func reauthenticate() async throws -> AuthenticationToken {
@MainActor func reauthenticate() async throws {
guard let user = Auth.auth().currentUser else {
throw AuthServiceError.reauthenticationRequired("No user currently signed-in")
}
Expand All @@ -44,7 +44,6 @@ extension GoogleOperationReauthentication {
let credential = try await googleProvider.createAuthCredential()
try await user.reauthenticate(with: credential)

return .firebase("")
} catch {
throw AuthServiceError.signInFailed(underlying: error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ protocol OAuthOperationReauthentication {
}

extension OAuthOperationReauthentication {
@MainActor func reauthenticate() async throws -> AuthenticationToken {
@MainActor func reauthenticate() async throws {
guard let user = Auth.auth().currentUser else {
throw AuthServiceError.reauthenticationRequired("No user currently signed-in")
}

do {
let credential = try await oauthProvider.createAuthCredential()
try await user.reauthenticate(with: credential)

return .firebase("")
} catch {
throw AuthServiceError.signInFailed(underlying: error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ protocol TwitterOperationReauthentication {
}

extension TwitterOperationReauthentication {
@MainActor func reauthenticate() async throws -> AuthenticationToken {
@MainActor func reauthenticate() async throws {
guard let user = Auth.auth().currentUser else {
throw AuthServiceError.reauthenticationRequired("No user currently signed-in")
}

do {
let credential = try await twitterProvider.createAuthCredential()
try await user.reauthenticate(with: credential)

return .firebase("")
} catch {
throw AuthServiceError.signInFailed(underlying: error)
}
Expand Down
Loading