fix: prevent infinite reload loop in OAuth deep link handling and clean up comments in LoginView
This commit is contained in:
@@ -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',
|
||||
@@ -277,5 +287,6 @@ const registerCapacitorListeners = () => {
|
||||
|
||||
export {
|
||||
registerCapacitorListeners,
|
||||
pushNotificationListenerRegistration as registerPushNotifications,
|
||||
pushNotificationListenerRegistration as registerPushNotifications
|
||||
}
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user