writefreely / writefreely-swiftui-multiplatform

Source code for the WriteFreely SwiftUI app for iOS, iPadOS, and macOS
https://writefreely.org/apps/ios
GNU General Public License v3.0
110 stars 10 forks source link

False positive on login #119

Closed AngeloStavrow closed 3 years ago

AngeloStavrow commented 4 years ago

Sometimes, logging in to the app appears successful from the settings screen, but in fact it fails silently, with no content getting pulled in from the server.

The workaround is to "logout" and then log back in.

AngeloStavrow commented 3 years ago

I've also seen similar false-positive logouts, where it looks like you've logged out, but lo and behold, you get stuck in a weird pseud-logged-out state. I suspect it may be related to writeas/writefreely-swift#25 — i.e., silent failures on some of the API responses.

AngeloStavrow commented 3 years ago

This is a bit of a weird bug: when it happens, the app appears to get a valid access token from the server, but when it proceeds with fetching user content from the server after logout, those requests come back with a 401: Unauthorized. I've confirmed that the access token is indeed invalidated by the server, but no DELETE request appears to have been sent to /api/auth/me to do so.

The PR in #124 to fix this therefore applies a defensive fix, checking for a valid token when requesting user content.