Skip to content

Commit 01fa243

Browse files
authored
fix(auth): Dismiss UI first before sending callback for HostedUI (#820)
1 parent c2fe144 commit 01fa243

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

AmplifyPlugins/Auth/AWSCognitoAuthPlugin/Dependency/AuthenticationProviderAdapter+SignIn.swift

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -149,29 +149,27 @@ extension AuthenticationProviderAdapter {
149149
self.awsMobileClient.showSignIn(navigationController: navController,
150150
signInUIOptions: SignInUIOptions(),
151151
hostedUIOptions: hostedUIOptions) { [weak self] state, error in
152-
defer {
153-
DispatchQueue.main.async {
154-
navController.dismiss(animated: false)
155-
}
156-
}
157-
guard let self = self else { return }
158-
159-
if let error = error {
160-
let authError = self.convertSignUIErrorToAuthError(error)
161-
completionHandler(.failure(authError))
162-
return
163-
}
164-
165-
guard let state = state, state == .signedIn else {
166-
167-
let error = AuthError.unknown("""
168-
signInWithWebUI did not produce a valid result.
169-
""")
170-
completionHandler(.failure(error))
171-
return
172-
}
173-
let authResult = AuthSignInResult(nextStep: .done)
174-
completionHandler(.success(authResult))
152+
153+
DispatchQueue.main.async {
154+
navController.dismiss(animated: false) {
155+
guard let self = self else { return }
156+
157+
if let error = error {
158+
let authError = self.convertSignUIErrorToAuthError(error)
159+
completionHandler(.failure(authError))
160+
return
161+
}
162+
163+
guard let state = state, state == .signedIn else {
164+
165+
let error = AuthError.unknown("signInWithWebUI did not produce a valid result.")
166+
completionHandler(.failure(error))
167+
return
168+
}
169+
let authResult = AuthSignInResult(nextStep: .done)
170+
completionHandler(.success(authResult))
171+
}
172+
}
175173
}
176174

177175
})

0 commit comments

Comments
 (0)