bitsy-ai / printnanny-os

Image repository, change logs, and issue tracking for PrintNanny OS
GNU Affero General Public License v3.0
23 stars 2 forks source link

Fetch user data only when authentication session is set #298

Closed leigh-johnson closed 1 year ago

leigh-johnson commented 1 year ago

Describe the bug

We're currently attempting to fetch user data on every page load (even if the authentication session is not set). This creates unnecessary pressure on the API deployments after sending a mass email. Since we're using database-based persistent sessions, Django will open a db connection even on a request that's missing authentication creds, to return session id along with the 403 response.

Instead, we should only attempt to fetch user data if an auth session is set in browser local storage.