Closed mwkhan1983 closed 3 years ago
Another option would be not to logout the user if they are filling out a form. Set the current activity in the onCreate
of the CovidJsonFormActivity
and clear it onStop
.
Then check what activity is currently visible before deciding to logout or not. This may be an easier and more efficient lift.
I have checked by setting up the activity in CovidJsonFormActivity
but it's not working because there is a process before starting the activity and it takes a time to load and in the meantime logout method called before setting up the activity.
@syedowaisali90 what process are you referring to?
what do is meant by it's not working? what about invoking this function makes it not work?
it's just processed all the components before starting up the form activity and it takes some time that' why we are showing the loader.
what exactly is the issue with that? does logout happen after the form is already launched?
yes, logout happens after the form is already lunched https://drive.google.com/file/d/15BnnMpFqrg6qdLn0R3Si2eeweMxQGqge/view
is this after making the change here https://github.com/onaio/rdt-standard/issues/958#issuecomment-821310139? Why would that happen?
https://github.com/onaio/rdt-standard/issues/958#issuecomment-821310139 this change won't work as i mentioned here https://github.com/onaio/rdt-standard/issues/958#issuecomment-822229869
the video you shared, https://github.com/onaio/rdt-standard/issues/958#issuecomment-826786121 is it after making the change or not?
No
@syedowaisali90 could you provide a detailed description or short video of what happens when you apply the change? I don't currently understand what is meant by it doesn't work.
Here is a scenario:
userAuth
has triggered in the background.userAuth
in progress and meanwhile, a user tried to open a form. CovidJsonFormActivity
. userAuth
gets completed.userAuth
tried to get a current from RDTApplication
class.RDTApplication
class. Because of form launch still in progress.userAuth
tried to logout and after that startActivity
method get called and launched the form. RDTApplication
class.userAuth
has been already triggered.Cool, I still don't see why the service having already started is an issue because if at the point it's calling logout the form activity is already launched/visible, then the form activity would have already registered itself as the current activity and logout should not happen. Unless you're saying logout happens while in 3 (the spinner is showing).
Are you able to reproduce forced logout when the form is showing for this scenario https://github.com/onaio/rdt-standard/issues/958#issuecomment-827400624?
I mean this Unless you're saying logout happens while in 3 (the spinner is showing).
at this moment we don't have a CovidJsonFormActivity
in RDTApplication
class and this happened frequently. As you have seen here https://github.com/onaio/rdt-standard/issues/958#issuecomment-826786121
https://github.com/onaio/rdt-standard/issues/958#issuecomment-826786121 shows that logout happens while the form is already launched, not while the spinner is showing.
@vincent-karuri @syedowaisali90 Please see attached video. Issue is occurring again. User is filling in the data not knowing session has expired and when complete form is filled and submitted, data is not saved as user has already logged out in the background.
The authentication check once the form opens was working well. It was not allowing user to enter data and logging out. Not sure why we changed that.
@mwkhan1983 What was merged was supposed to ensure that the app doesn't log out when a form is open . If this is still happening, we need to list the steps to reproduce that behaviour and get it definitively fixed . I'm not sure what was working before that is not working now since that is the bug described in the issue (logging out when filling out a form).
@vincent-karuri App doesn't logout when form is open but when you submit the form, data is not saved because user is already logged out in the background. This is an issue because user would not know that despite submitting data, it is not saved.
So original issue described asked for one of the two things to happen:
Through authorization check when opening form, we were able to achieve 2.
logged out in the background
, could you elaborate?@mwkhan1983 one cannot make the conclusion in 1 by looking at the video. There should be no "background logout" if the current activity is a form activity (has @syedowaisali90 confirmed the "background logout" during debugging?).
I think all steps should ideally be logged on the issue so that they are visible to everyone involved.
Authz has always been done in a background thread. Again, this is not a conclusion that can be made by looking at the video. Even if we revert the authz to happen on every form launch, it's simply coincidental that the authz check happens fast enough before too many details are entered into the form and is not a definitive fix imo.
@syedowaisali90 could you check why logout happens soon after submission, and also explore if this is a problem with the form activity being cleared before submission is complete?
@vincent-karuri could you test the app from step 3 here https://github.com/onaio/rdt-standard/issues/958#issuecomment-831130836 so that you see the real problem.
@syedowaisali90, @mwkhan1983 has described what is happening behaviorally. We should try figure out why what is happening in code. There may be other reasons but two things to keep in mind is:
VerifyAuthorizationTask
runs when saving a form@vincent-karuri Here is the scenario https://github.com/onaio/rdt-standard/issues/958#issuecomment-827400624. The main reason, why it's happening just because syncUtils.logoutUser();
get called called during the form loading.
When we try to open a form so it takes some time to open a CovidJsonFormActivity
so that's why I have used caller activity as a check instead of CovidJsonFormActivity
.
Currently, we have only two caller activity the one is CovidPatientProfileActivity
and the second is CovidPatientRegisterActivity
and I have tested that now it's working fine.
Either user should be able to save data entered upon submit or delay should not be long enough to allow user to keep entering data.