fix: prevent infinite reload loop in OAuth deep link handling and clean up comments in LoginView

This commit is contained in:
Mo Tarbin
2026-07-08 12:46:42 -04:00
parent fd3f7f4a37
commit 181156de10
2 changed files with 13 additions and 3 deletions

View File

@@ -48,6 +48,16 @@ const handleOAuthDeepLink = async url => {
const state = urlObj.searchParams.get('state')
if (code && state) {
// getLaunchUrl() persists across every WebView reload caused by
// window.location.href. If we're already on the OAuth handler page with
// the same code, skip re-navigating to avoid an infinite reload loop.
const currentCode = new URLSearchParams(window.location.search).get(
'code',
)
if (window.location.pathname === '/auth/oauth2' && currentCode === code) {
return
}
// Store the OAuth params for the app to pick up
await Preferences.set({
key: 'oauth_callback',
@@ -258,7 +268,7 @@ const registerCapacitorListeners = () => {
console.log('[NFC] appUrlOpen:', event.url)
handleUrlOpen(event.url)
})
mobileApp.addListener('appStateChange', ({ isActive }) => {
focusManager.setFocused(isActive)
})
@@ -277,5 +287,6 @@ const registerCapacitorListeners = () => {
export {
registerCapacitorListeners,
pushNotificationListenerRegistration as registerPushNotifications,
pushNotificationListenerRegistration as registerPushNotifications
}

View File

@@ -310,7 +310,6 @@ const LoginView = () => {
const state = generateRandomState()
if (Capacitor.isNativePlatform()) {
// For mobile devices, use a custom URL scheme for the redirect
const redirectUri = 'donetick://auth/oauth2'
const params = new URLSearchParams({