Jan 17 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Steve S. | has entered the room |
Steve S. |
Hi Mark!
|
Mark M. |
hello, Steve!
|
Mark M. |
how can I help you today?
|
Steve S. |
Let me paste in my question:
|
Steve S. |
View paste
|
Mark M. |
"Because the user can potentially navigate to several different activities while the Rest request is being processed" -- perhaps (part of) the solution is to prevent navigation until the logout request is settled one way or the other
|
Steve S. |
ok.
|
Mark M. |
normally, you don't want to prevent navigation just because you are doing network I/O
|
Mark M. |
login and logout are special cases
|
Steve S. |
Right.
|
Steve S. |
I see
|
Mark M. |
beyond that, you can either use inheritance (activities inheriting from a base that handles the event) or composition (activities hold a controller that handles the event)
|
Steve S. |
Originally I prevented navigation during network I/O but have rewritten my app to allow that (based on prior chats we've had)
|
Mark M. |
and normally that's the right answer
|
Jan 17 | 4:00 PM |
Mark M. |
but, "change the world" events (login, logout, registration, delete account, etc.) may require breaking that pattern
|
Mark M. |
after all, if the user requests logout, then attempts to modify something, what happens?
|
Steve S. |
I see. That's very helpful.
|
Steve S. |
How should I prevent navigation while the logout request is being processed? Use a modal dialog?
|
Mark M. |
possibly
|
Steve S. |
ok
|
Mark M. |
are you holding onto any sort of credentials in memory, based on the login?
|
Mark M. |
(e.g., tokens that you have to place on the REST requests)
|
Steve S. |
no login credentials per se, but other information about the user
|
Mark M. |
ok
|
Steve S. |
yes, oauth tokens.
|
Mark M. |
then another possibility is to clear out those tokens quickly after the logout request is made, and control navigation based on whether you have a token
|
Mark M. |
or, just send them straight to the login screen, on the grounds that "what would a logout failure mean with respect to those tokens anyway?"
|
Steve S. |
what do you mean by "control navigation based on whether you have a token"?
|
Mark M. |
reactively, you would check the token on click listeners and such, deciding whether to navigate based on the existence of the token
|
Jan 17 | 4:05 PM |
Mark M. |
proactively, you would raise a logout-pending event, and disable navigation until... sometime
|
Mark M. |
the more I think about this, the more my gut is telling me that they should just be sent straight to the login screen after choosing logout
|
Mark M. |
if you cannot safely let them log in until the logout wraps up, handle that when they click the "login" button (e.g., queue the login attempt until the logout is confirmed)
|
Steve S. |
so from the user's point of view, the logout request would never fail, even if the internal Rest request fails.
|
Mark M. |
right
|
Mark M. |
simply because your app at that moment is in an iffy state anyway with respect to the pre-logout token
|
Mark M. |
and my guess is that you're safer forcing a fresh login
|
Mark M. |
whoever is handling the server side may have their own opinion on this
|
Steve S. |
ok. that makes a lot of sense. i will test, but i think the behavior of the backend allows logging in twice without logging out.
|
Jan 17 | 4:10 PM |
Steve S. |
your point that allowing navigation while a Rest request is pending is something that's appropriate in many circumstances but not all is very helpful. i'll think through the app's behavior again based on that.
|
Mark M. |
pretty much whenever you see somebody like me speak in absolutes, we're doing that to simplify the discussion :-)
|
Steve S. |
sure.
|
Steve S. |
no more questions today.
|
Mark M. |
OK
|
Steve S. |
by the way, the last time i tried to print out the session, i didn't get the entire transcript - the last part was cut off. i'm wondering if there's something i'm doing on my end that could be causing that.
|
Mark M. |
do you mean the transcripts from https://commonsware.com/office-hours/ ?
|
Mark M. |
or do you mean the current contents of your browser window, like it is now?
|
Steve S. |
yes, the transcripts. we exchanged emails about the problem a few weeks ago.
|
Mark M. |
right, and that was a case where I had screwed up the transcript download, then fixed it
|
Mark M. |
are you still having problems?
|
Mark M. |
and, if so, which transcript are you trying?
|
Mark M. |
I have never tried printing one of these, so I don't know what to expect :-)
|
Steve S. |
it's been a couple of weeks, but it did happen again. i don't remember which transcript - i was able to get what i needed.
|
Mark M. |
if you run into future transcript problems, drop me a line
|
Steve S. |
ok. i'll try printout out the transcript for today's session after its' ended. i'll let you know if there's a problem.
|
Steve S. |
thank you so much! i appreciate your help.
|
Jan 17 | 4:15 PM |
Mark M. |
you're welcome!
|
Steve S. |
have a good rest of the day!
|
Mark M. |
you too!
|
Steve S. | has left the room |
Jan 17 | 4:55 PM |
Mark M. | turned off guest access |