Skip to content

Fix blank profile after registration#2923

Merged
lifeart merged 1 commit into
masterfrom
fix-empty-profile-after-registration
Jun 26, 2026
Merged

Fix blank profile after registration#2923
lifeart merged 1 commit into
masterfrom
fix-empty-profile-after-registration

Conversation

@lifeart

@lifeart lifeart commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Problem

Right after a user registers, their profile page renders blank — empty first/last name, gender unselected, and Год рождения: NaN with an "invalid date" error.

![symptom: blank profile after registration]

Root cause

A navigation-vs-task race in registration-form. registrationTask runs:

registerUserawait loginTask.perform()patchUserInfo() (saves name/bornYear/gender) → loadCurrentUser() (refreshes the tracked userModel the profile reads).

The shared loginTask called router.transitionTo('index') the moment the session authenticated — in the middle of registrationTask. That navigation tears down the registration-form component, and ember-concurrency auto-cancels the still-running registrationTask before patchUserInfo + the refreshing loadCurrentUser complete. So userData.userModel keeps the empty pre-patch stub (it otherwise only repopulates in application.beforeModel at app boot), and a missing bornYear made fromLatestUserDto emit the literal string "NaN".

Tellingly, the existing integration test mocked session.isAuthenticated = false, so the transitionTo path — the buggy one — was never exercised.

Fix

  • registration-form/index.gts — remove the redirect from loginTask; move it to the end of registrationTask, after patchUserInfo + loadCurrentUser. The redirect now fires whenever the session is authenticated, even if the profile PATCH fails, so a fully-registered, authenticated user is never trapped on the form (re-submitting would re-run registerUser → "user already exists" dead-end, and loginInProgress would leave a stuck spinner). They can finish their profile on the profile page, which patches each field on input.
  • services/network.tsfromLatestUserDto now yields an empty birthday string instead of "NaN" when bornYear is missing/invalid, and drops the vestigial new Date() round-trip.

Tests

  • network-test.jsbirthday parsed from bornYear; missing bornYear'' (fails on old code, which produced "NaN").
  • registration-form component test — redirect happens only after the profile is patched and reloaded (fails on the old ordering); and the user is still redirected when the profile patch fails after auth.

Verification

  • pnpm run lint:types (ember-tsc), ESLint, and ember-template-lint all pass on the changed files.
  • ⚠️ The ember test runner does not boot on this repo (pre-existing global Could not find module ./package error, reproduces on a clean master), so the new tests are traced-by-hand to fail-on-old / pass-on-new rather than executed locally. CI will run them.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

Frontend test coverage: 72.59% (+0.09% compared to 72.5% on base)

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

Gradle Unit and Integration Test Results

523 tests  ±0   521 ✔️ ±0   38s ⏱️ ±0s
116 suites ±0       2 💤 ±0 
116 files   ±0       0 ±0 

Results for commit 8a04fa4. ± Comparison against base commit fcec536.

♻️ This comment has been updated with latest results.

The profile page rendered empty right after sign-up: no first/last name,
gender unselected, and "Год рождения: NaN" / invalid-date.

Root cause is a navigation-vs-task race in registration-form. The shared
loginTask called router.transitionTo('index') the moment the session
authenticated — in the middle of registrationTask. That navigation tears down
the registration-form component, and ember-concurrency auto-cancels the still
running registrationTask before patchUserInfo() and the refreshing
loadCurrentUser() complete. So userData.userModel kept the empty pre-patch stub
(loadCurrentUser otherwise only runs in application.beforeModel at boot), and a
missing bornYear made fromLatestUserDto emit the literal string "NaN".

Fixes:
- registration-form: remove the redirect from loginTask and move it to the end
  of registrationTask, after patchUserInfo + loadCurrentUser. The redirect now
  fires whenever the session is authenticated, even if the profile PATCH fails,
  so a fully-registered user is never trapped on the form (re-submitting would
  re-run registerUser and fail with "user already exists"); they can finish
  their profile on the profile page, which patches each field on input.
- network: fromLatestUserDto now yields an empty birthday string instead of
  "NaN" when bornYear is missing/invalid, and drops the vestigial Date
  round-trip.

Tests:
- network: birthday parsed from bornYear; missing bornYear -> '' (fails on old).
- registration-form: redirect happens only after the profile is patched and
  reloaded (fails on old ordering); and the user is still redirected when the
  profile patch fails after auth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lifeart lifeart force-pushed the fix-empty-profile-after-registration branch from 98d6ff9 to 8a04fa4 Compare June 26, 2026 20:39
@github-actions

Copy link
Copy Markdown

Frontend test coverage: 72.61% (+0.14% compared to 72.47% on base)

@sonarqubecloud

Copy link
Copy Markdown

@lifeart lifeart merged commit 836a854 into master Jun 26, 2026
10 checks passed
@lifeart lifeart deleted the fix-empty-profile-after-registration branch June 26, 2026 21:12
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