Skip to content

Commit

Permalink
Guard against the last one
Browse files Browse the repository at this point in the history
  • Loading branch information
Firehed committed May 30, 2024
1 parent 3cb2a7d commit 533a8c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/SnapAuth/SnapAuth+ASACPCP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import AuthenticationServices
@available(macOS 12.0, iOS 15.0, tvOS 16.0, visionOS 1.0, *)
extension SnapAuth: ASAuthorizationControllerPresentationContextProviding {
public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
// FIXME: do not force unwrap
logger.debug("presentation anchor")
guard anchor != nil else {
// There's currently no logical path here since the three
// entrypoints all set the anchor, but in case more direct control
// paths are exposed this should prevent an unwrapping crash
logger.error("Presentation anchor missing, providing default")
return ASPresentationAnchor.default
}
return anchor!
}
}

0 comments on commit 533a8c8

Please sign in to comment.