@@ -115,16 +115,36 @@ class EmbeddedAuthActivity : FronteggBaseActivity() {
115115 return
116116 }
117117
118- Log .d(TAG , " Checking load conditions: isStepUpAuthorization=${fronteggAuth.isStepUpAuthorization.value} , initializing=${fronteggAuth.initializing.value} , isAuthenticated=${fronteggAuth.isAuthenticated.value} " )
118+ // Always load URL for password reset and other account actions that don't require authentication
119+ // These URLs should be accessible regardless of auth state (initializing/authenticated)
120+ // This is especially important for Flutter apps where initialization may complete after activity starts
121+ // Check this FIRST before accessing fronteggAuth properties to avoid initialization issues
122+ val isPasswordResetOrAccountAction = webViewUrl?.contains(" /oauth/account/reset-password" ) == true ||
123+ webViewUrl?.contains(" /oauth/account/verify-email" ) == true ||
124+ webViewUrl?.contains(" /oauth/account/verify-phone" ) == true ||
125+ webViewUrl?.contains(" /oauth/account/accept-invitation" ) == true ||
126+ webViewUrl?.contains(" /oauth/account/activate" ) == true ||
127+ webViewUrl?.contains(" /oauth/account/invitation/accept" ) == true
119128
120129 // Always load URL for social login redirects (oauth/account/social/success)
121130 val isSocialLoginRedirect = webViewUrl?.contains(" /oauth/account/social/success" ) == true
122- Log .d(TAG , " isSocialLoginRedirect: $isSocialLoginRedirect " )
123131
124- if (isSocialLoginRedirect ||
125- (fronteggAuth.isStepUpAuthorization.value ||
126- (! fronteggAuth.initializing.value &&
127- ! fronteggAuth.isAuthenticated.value))
132+ Log .d(TAG , " isPasswordResetOrAccountAction: $isPasswordResetOrAccountAction , isSocialLoginRedirect: $isSocialLoginRedirect " )
133+
134+ // If it's an account action URL (reset-password, etc.), load immediately without checking auth state
135+ if (isPasswordResetOrAccountAction || isSocialLoginRedirect) {
136+ Log .d(TAG , " loadUrl (account action/social redirect): $webViewUrl " )
137+ webView.loadUrl(webViewUrl!! )
138+ webViewUrl = null
139+ return
140+ }
141+
142+ // For other URLs, check auth state
143+ Log .d(TAG , " Checking load conditions: isStepUpAuthorization=${fronteggAuth.isStepUpAuthorization.value} , initializing=${fronteggAuth.initializing.value} , isAuthenticated=${fronteggAuth.isAuthenticated.value} " )
144+
145+ if (fronteggAuth.isStepUpAuthorization.value ||
146+ (! fronteggAuth.initializing.value &&
147+ ! fronteggAuth.isAuthenticated.value)
128148 ) {
129149 Log .d(TAG , " loadUrl $webViewUrl " )
130150 webView.loadUrl(webViewUrl!! )
@@ -217,6 +237,28 @@ class EmbeddedAuthActivity : FronteggBaseActivity() {
217237 if (intent.data != null && webViewUrl == null ) {
218238 consumeIntent(intent)
219239 }
240+
241+ // Fallback: Retry loading URL if it wasn't loaded in onCreate due to initialization state
242+ // This can happen when app is opened from terminated state in Flutter
243+ // Even though reset-password URLs should load immediately, this ensures they load once initialization completes
244+ if (webViewUrl != null ) {
245+ val isPasswordResetOrAccountAction = webViewUrl?.contains(" /oauth/account/reset-password" ) == true ||
246+ webViewUrl?.contains(" /oauth/account/verify-email" ) == true ||
247+ webViewUrl?.contains(" /oauth/account/verify-phone" ) == true ||
248+ webViewUrl?.contains(" /oauth/account/accept-invitation" ) == true ||
249+ webViewUrl?.contains(" /oauth/account/activate" ) == true ||
250+ webViewUrl?.contains(" /oauth/account/invitation/accept" ) == true ||
251+ webViewUrl?.contains(" /oauth/account/social/success" ) == true
252+
253+ // Always load account action URLs regardless of auth state
254+ if (isPasswordResetOrAccountAction ||
255+ fronteggAuth.isStepUpAuthorization.value ||
256+ (! fronteggAuth.initializing.value && ! fronteggAuth.isAuthenticated.value)) {
257+ Log .d(TAG , " Retrying loadUrl in onResume: $webViewUrl " )
258+ webView.loadUrl(webViewUrl!! )
259+ webViewUrl = null
260+ }
261+ }
220262
221263 }
222264
0 commit comments