talklittle / reddit-is-fun

OLD VERSION 1.3 of reddit is fun -- Android app to interact with reddit.com
GNU General Public License v3.0
372 stars 157 forks source link

App doesn't handle invalid session errors #251

Closed bboe closed 12 years ago

bboe commented 12 years ago

It took me a week to remember that I used the "log out of all other sessions" feature on reddit to invalidate any other sessions (this also occurs when changing the password) and that explained why I could no longer vote, comment, submit, or view my inbox using Reddit is Fun. However, Reddit is Fun never notified me that I was logged out, only said that this action cannot be completed at this time.

Reddit is Fun should detect the invalid user error (I'm not sure what exact error it is right now) and prompt the user to log in, or at least notify the user that their session is no longer valid.

talklittle commented 12 years ago

@bboe thank you for pointing out this bug! I have gotten some user reports that kept me scratching my head about why commenting would sometimes fail for them. I'll make sure this gets fixed in the next version.

talklittle commented 12 years ago

I fixed this insofar as modhash returned with a Listing is empty or null when you get logged out via that "log out of all other sessions" feature. I hope this is not too aggressive, but now anytime you load a Listing via the app, which pretty much means any time you open the app, it will detect empty modhash and show a Toast that you've been logged out.

There are still a few remaining edge cases like if you enter the app via a Share intent and I still don't handle the error response after POST, only upon loading a Listing. But I think this fix will handle at least 95% of the error cases.

bboe commented 12 years ago

Awesome. Another thing you can do is to look for the USER_REQUIRED error in the json results for submit and comment. The response should contain the following assuming you have 'api_type:json' in the POST headers:

{"json": {"errors": [["USER_REQUIRED", "please login to do that", null]]}}
talklittle commented 12 years ago

Sweet thanks for the info, that looks pretty simple. I'll need to think about how I can implement a friendly user interface around it.