I realize that this modifier was created to be attached to the view that would be present for a callback listener. But even in the event that this modifier was positioned elsewhere, it should fail silently rather than force unwrap cookies. There could be other deeplinks happening at the same time. Alternatively we should be able to apply this modifier to the root view or even listen to a specific route and roward it accordlingly. Nevertheless, we shouldn't be force unwrapping anything here.
Maybe i'm misunderstanding the logic in the modifier.
public func registerOAuthHandler() -> some View {
onOpenURL { url in
WebAuthComponent.handleIncomingCookie(from: url)
}.onReceive(NotificationCenter.default.publisher(for: notificationType)) { _ in
WebAuthComponent.onCallback()
}
}
I was under the impression that this modifier was required. Are we suppose to be building our own?
i'd think we could modify this to validate the URLComponents before continuing..
public static func handleIncomingCookie(from url: URL) {
guard let components = URLComponents(string: url.absoluteString)!,
validateQueryComponent(components) else {
return
}
let components = URLComponents(string: url.absoluteString)!
let cookieParts = [String: String](uniqueKeysWithValues: components.queryItems!.map {
($0.name, $0.value!)
})
func validateQueryComponents(_ components: URLComponents) -> Bool {
.... to validate
}
that way the app doesn't have to be open to recieve the url, and not crash any other deeplinks i care to listen for elsewhere in the app.
Recommended threads
- How to verify an user using AppWrite Fun...
I have seen similar questions but none whose solutions serve me. I have a function to verify a user with their secret and their id: https://blahblah.appwrite.gl...
- No user data after Google OAuth
I'm attempting to integrate Google sign in to an ios app - it seems to work, and redirects back to app. It does create a new user, (or a new user session after...
- How do I properly setup OAuth2 flow for ...
This is a duplicate of now closed thread **[ CLOSE ] How do I connect Google oauth2 to my ios app?** with a more precisely formulated question Hello everyone!...