Skip to content

Commit

Permalink
Merge pull request #443 from supabase-community/fix-apple
Browse files Browse the repository at this point in the history
Fix apple auth triggering automatically
  • Loading branch information
jan-tennert authored Jan 30, 2024
2 parents 6cf1fdc + 2724abc commit 3d9502d
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,30 @@ actual fun ComposeAuth.rememberSignInWithApple(
val scope = rememberCoroutineScope()

LaunchedEffect(key1 = state.started) {

if (config.loginConfig["apple"] == null) {
fallback.invoke()
state.reset()
return@LaunchedEffect
}

val appleIDProvider = ASAuthorizationAppleIDProvider()
val request = appleIDProvider.createRequest().apply {
requestedScopes = listOf(ASAuthorizationScopeFullName, ASAuthorizationScopeEmail)
nonce = (config.loginConfig["apple"] as? AppleLoginConfig)?.nonce
}

val controller = ASAuthorizationController(listOf(request)).apply {
delegate = authorizationController(scope) {
onResult.invoke(it)
if(state.started) {
if (config.loginConfig["apple"] == null) {
fallback.invoke()
state.reset()
return@LaunchedEffect
}

presentationContextProvider = presentationAnchor()
val appleIDProvider = ASAuthorizationAppleIDProvider()
val request = appleIDProvider.createRequest().apply {
requestedScopes = listOf(ASAuthorizationScopeFullName, ASAuthorizationScopeEmail)
nonce = (config.loginConfig["apple"] as? AppleLoginConfig)?.nonce
}

val controller = ASAuthorizationController(listOf(request)).apply {
delegate = authorizationController(scope) {
onResult.invoke(it)
state.reset()
}

presentationContextProvider = presentationAnchor()

}
controller.performRequests()
}
controller.performRequests()
}

return state
Expand Down

0 comments on commit 3d9502d

Please sign in to comment.