Skip to content

Refresh auth session with server-authoritative current user data#59

Merged
RMCampos merged 3 commits into
mainfrom
copilot/bugfix-refresh-user-data
May 19, 2026
Merged

Refresh auth session with server-authoritative current user data#59
RMCampos merged 3 commits into
mainfrom
copilot/bugfix-refresh-user-data

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

Refreshing a session previously rotated only the JWT, leaving AuthContext.user stale until re-login. This change makes refresh also rehydrate current user profile data so cross-device/profile updates are reflected after page reload/session refresh.

  • Backend: add authenticated current-user endpoint

    • Added GET /rest/users/me in UserController.
    • Added AuthService#getCurrentUserResponse() to return the logged-in user as UserResponse (including gravatar hash logic used elsewhere).
  • Frontend: refresh now updates token and user context

    • Added ApiConfig.currentUserUrl (/rest/users/me).
    • Updated AuthProvider.checkCurrentAuthUser() to:
      1. call /rest/user-sessions/refresh
      2. call /rest/users/me
      3. persist fresh user in USER_DATA and update in-memory context.
  • Focused test updates

    • Extended UserControllerTest with authorized/unauthorized coverage for GET /rest/users/me.
    • Updated AuthProvider tests to mock refresh + current-user fetch sequence and assert user/localStorage refresh behavior.
// AuthProvider.tsx (refresh path)
const bearerToken = await api.getJSON(ApiConfig.refreshTokenUrl);
if (bearerToken?.token) {
  const currentUser = await api.getJSON(ApiConfig.currentUserUrl);
  const userLocal = updateUserSession(currentUser, bearerToken.token);
  if (userLocal) {
    setSigned(true);
    setUser(userLocal);
  }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-8020627fcb755699/dbs/java/working/files-to-index14157248185019752309.list --sourceArchiveDir=/tmp/codeql-scratch-8020627fcb755699/dbs/java/src --outputDir=/tmp/codeql-scratch-8020627fcb755699/dbs/java/trap/java efresh-user-data it (dns block)
  • download.cypress.io
    • Triggering command: /usr/local/bin/node node dist/index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 18, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/RMCampos/tasknote/sessions/3f01367a-baee-4bbe-8f66-f04da58d485f

Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix user data update after refreshing session Refresh auth session with server-authoritative current user data May 18, 2026
Copilot AI requested a review from RMCampos May 18, 2026 23:57
@RMCampos RMCampos marked this pull request as ready for review May 18, 2026 23:57
@RMCampos RMCampos merged commit f34c359 into main May 19, 2026
4 checks passed
@RMCampos RMCampos deleted the copilot/bugfix-refresh-user-data branch May 19, 2026 01:26
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.

Bug: update user after refreshing

2 participants