Skip to content

Commit

Permalink
[Auth] Better keychain error descriptions (#13600)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Sep 6, 2024
1 parent fab6834 commit ed4269b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion FirebaseAuth/Sources/Swift/Utilities/AuthErrorUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ class AuthErrorUtils: NSObject {
}

static func keychainError(function: String, status: OSStatus) -> Error {
let reason = "\(function) (\(status))"
let message = SecCopyErrorMessageString(status, nil) as String? ?? ""
let reason = "\(function) (\(status)) \(message)"
return error(code: .keychainError, userInfo: [NSLocalizedFailureReasonErrorKey: reason])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate {
}

private func toggleAccessGroup() {
if AppManager.shared.auth().userAccessGroup == nil {
guard let bundleDictionary = Bundle.main.infoDictionary,
let group = bundleDictionary["AppIdentifierPrefix"] as? String else {
fatalError("Configure AppIdentifierPrefix in the plist")
do {
if AppManager.shared.auth().userAccessGroup == nil {
guard let bundleDictionary = Bundle.main.infoDictionary,
let group = bundleDictionary["AppIdentifierPrefix"] as? String else {
fatalError("Configure AppIdentifierPrefix in the plist")
}
try AppManager.shared.auth().useUserAccessGroup(group +
"com.google.firebase.auth.keychainGroup1")
} else {
try AppManager.shared.auth().useUserAccessGroup(nil)
}
AppManager.shared.auth().userAccessGroup = group + "com.google.firebase.auth.keychainGroup1"
} else {
AppManager.shared.auth().userAccessGroup = nil
} catch {
fatalError("Failed to set userAccessGroup with error \(error)")
}
}

Expand Down

0 comments on commit ed4269b

Please sign in to comment.