Skip to content

Commit 62b80d0

Browse files
fix: use secondary app if it is passed into FirebaseAuthUI
1 parent c5461b6 commit 62b80d0

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

auth/src/main/java/com/firebase/ui/auth/AuthFlowController.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ class AuthFlowController internal constructor(
158158
*/
159159
fun createIntent(context: Context): Intent {
160160
checkNotDisposed()
161-
return FirebaseAuthActivity.createIntent(context, configuration)
161+
return FirebaseAuthActivity.createIntent(
162+
context = context,
163+
configuration = configuration,
164+
authUI = authUI
165+
)
162166
}
163167

164168
/**

auth/src/main/java/com/firebase/ui/auth/FirebaseAuthActivity.kt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ class FirebaseAuthActivity : ComponentActivity() {
7777
super.onCreate(savedInstanceState)
7878
enableEdgeToEdge()
7979

80-
// Extract configuration from cache using UUID key
81-
val configKey = intent.getStringExtra(EXTRA_CONFIGURATION_KEY)
82-
configuration = if (configKey != null) {
83-
configurationCache.remove(configKey)
80+
// Extract configuration and auth instance from cache using UUID key
81+
val launchKey = intent.getStringExtra(EXTRA_CONFIGURATION_KEY)
82+
configuration = if (launchKey != null) {
83+
configurationCache.remove(launchKey)
8484
} else {
8585
null
8686
} ?: run {
@@ -90,7 +90,16 @@ class FirebaseAuthActivity : ComponentActivity() {
9090
return
9191
}
9292

93-
authUI = FirebaseAuthUI.getInstance()
93+
authUI = if (launchKey != null) {
94+
authUICache.remove(launchKey)
95+
} else {
96+
null
97+
} ?: run {
98+
// Missing auth instance, finish with error
99+
setResult(RESULT_CANCELED)
100+
finish()
101+
return
102+
}
94103

95104
// Extract email link if present
96105
val emailLink = intent.getStringExtra(EmailLinkConstants.EXTRA_EMAIL_LINK)
@@ -191,14 +200,18 @@ class FirebaseAuthActivity : ComponentActivity() {
191200
*/
192201
internal fun createIntent(
193202
context: Context,
194-
configuration: AuthUIConfiguration
203+
configuration: AuthUIConfiguration,
204+
authUI: FirebaseAuthUI = FirebaseAuthUI.getInstance()
195205
): Intent {
196206
val configKey = UUID.randomUUID().toString()
197207
configurationCache[configKey] = configuration
208+
authUICache[configKey] = authUI
198209

199210
return Intent(context, FirebaseAuthActivity::class.java).apply {
200211
putExtra(EXTRA_CONFIGURATION_KEY, configKey)
201212
}
202213
}
214+
215+
private val authUICache = ConcurrentHashMap<String, FirebaseAuthUI>()
203216
}
204217
}

0 commit comments

Comments
 (0)