Skip to content

feat: add state injection#197

Open
azapg wants to merge 1 commit intomainfrom
state-injection
Open

feat: add state injection#197
azapg wants to merge 1 commit intomainfrom
state-injection

Conversation

@azapg
Copy link
Copy Markdown
Owner

@azapg azapg commented Mar 24, 2026

This PR injects a tiny state script with user and platform data into the frontend so in many cases we don't have to fetch and show loaders for stuff llike current user, whether they are admin or whether email is enabled

i haven't tested this right

@github-actions
Copy link
Copy Markdown

TODO Summary

Showing TODOs in changed files only

No TODOs found!


Last updated: 2026-03-24T22:17:53.452Z

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bfda3fce0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +106 to +110
if (!storedToken && injectedIsAuthenticated && injectedUser) {
setToken('injected-session')
setUser(injectedUser)
persist(null, injectedUser)
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid cookie-only auth state without a bearer token

When storedToken is missing but injected auth is present, this branch marks the client session authenticated and explicitly persists null for the token. In this codebase, the Axios interceptor only sends Authorization from localStorage (frontend-dev/src/lib/api.ts), while protected backend routes still depend on oauth2_scheme bearer tokens (src/fair_platform/backend/api/routers/auth.py#get_current_user). So in the reachable case of a valid access_token cookie but no localStorage token (e.g., storage cleared or cookie restored), the UI shows a logged-in state but all authenticated API calls fail with 401.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant