Login and logout issue in Reat native app

After logged into our app, sometime it’s automatically logging out and after 1-2 seconds, it’s logged in back. I observerd, the user ID which I am getting through useTracker is being undefined for a few seconds , that’s why login logout issue is happening for the react native app. Please help!

1 Like

Maybe @jkuester can help you.

1 Like

Hey @kritittwa which version of @meteorrn/core do you use? Does this only happen after a new login (user enters credentials) or also when using an existing login token?

1 Like

I think it would be best to depend on the Meteor.userId() at router level and also rely on something like this in the router:

const exp = localStorage.getItem('Meteor.loginTokenExpires')
  const iAmRemembered = exp && new Date(exp).getTime() > Date.now()

When I route things I first check if I am or eventually was logged in and then test for Meteor.userId().

Even in React depending on Meteor.userId() to switch components is flickery. It needs to be used as a conditional effect.

1 Like

Hi @jkuester , I am using @meteorrn/core 2.4.0 version. For both cases(new login & existing login token) the flickering issue is happening.

When are you experiencing the issue? On load of the app? Or in the middle of using the app while moving from one page to another?

1 Like

@kritittwa can you please add Meteor.isVerbose = true at the very top of your execution order (and outside any React component) and post what’s going on.

I’d like to know the specific state the userId is undefined and if it relates to the connection state (some issue I experienced in the past, where logout caused a disconnect for a short time).

hi @rjdavid, Auto Logout issue is happening on both cases first is if logged in our app and stay idle in home screen then and second if I navigated one page to another page then also this logout issue is happening.