You are mentioning two things in your question which seem key to answering it:
A) the app is in a state with data that could be lost if the user is not logged in.
B) the app needs to log back in to save the data.
If these are the constraints you should work around them accordingly:
- Devise a scheme in which you can save changes locally. Keep track of the syncing state with the server.
- If login status changes and something unexpected happens, unobtrusively alert the user and give her the opportunity to fix it.