From a9552f9a522444658f0fa16203d8754dacb97c88 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 22 Jul 2020 16:22:49 -0700 Subject: [PATCH] Fix Update authContext #33 --- CONTRIBUTORS.md | 1 + Sources/iOS/Auth+iOS.swift | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d80cca72..ce6a2a30 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -5,4 +5,5 @@ Contributors to the codebase, in reverse chronological order: - Dave Carlson, @drdavec - Pascal Pfiffner, @p2 +- Eric Mentele, @EricMentele diff --git a/Sources/iOS/Auth+iOS.swift b/Sources/iOS/Auth+iOS.swift index 26ad7c1a..29c99e4b 100644 --- a/Sources/iOS/Auth+iOS.swift +++ b/Sources/iOS/Auth+iOS.swift @@ -20,7 +20,9 @@ extension Auth { - parameter callback: The callback that is called when authorization completes or fails */ func authorize(with oauth: OAuth2, properties: SMARTAuthProperties, callback: @escaping ((OAuth2JSON?, OAuth2Error?) -> Void)) { - authContext = UIApplication.shared.keyWindow?.rootViewController + + let rootViewController = UIApplication.shared.keyWindow?.rootViewController + authContext = rootViewController?.presentedViewController ?? rootViewController oauth.authConfig.authorizeContext = authContext oauth.authConfig.authorizeEmbedded = properties.embedded