Redirect to the login view when login is required
When the UMAP_ALLOW_ANONYMOUS setting is False, we return the login url through a JSON response. We lost that ability in #1555.
The JS part was not following that link in that particular case and lead to more errors because the map was not saved (hence, no map_id).
For now, the current work on the map is lost because of the redirection and we have a confirmation dialog to quit the edited page with unsaved changes.
Maybe we should display a custom message instead of a brutal redirection? Like: you’re not logged in, do it in a separate tab to keep you work? (A bit ugly…)
Sidenote: we might want to use the redirect pattern/key in the JSON response that we already use for deletion and clone for consistency.
Thanks for the issue. I wonder: if the login is required, maybe we should login first before allowing the creation of a new map? 🤔
Humm, but with this proposal, the data is lost, no ?
The tricky part, that was done before #1555, was:
- sent a normal request
- receive a login_required
- to the login
- send again the initial request
- continue the js flow (sending other requests, etc.)
I wonder: if the login is required, maybe we should login first before allowing the creation of a new map? 🤔
There is an usage where users see a "prebuilt" map with remote data, so they can browse the data AND optionally save it later. Those users are not logged in. This is in use in the ANCT instance.: from the deveco app, people search for companies in their territory, and if they want to see it on a map, they are sent to uMap.
We iterated on this with @Aurelie-Jallut and I should have report this here. We plan to add a modal window to explicitly state that it's in playground mode with data loss if no account is created/logged in.
Two questions then:
- is "playground mode" the situation where the uMap instance does not accept anonymous map and the user is not logged in ? (We should still keep in mind the "preloaded map" scenario)
- does that mean we gived up on making the login working again during a save process (as before #1555) ?
To have it here too.
🤔 It's not clear to me that I shouldn't go there by reading this message. Should we explicitly state that "You won't be able to save your edits"?
Replaced by #2025