Skip to content

Fix: password signup shows JSON parse error when MAIL_URL is configured#10519

Merged
ArtyomSavchenko merged 1 commit intohcengineering:developfrom
spatialy:fix/signup-token-guard-10518
Feb 19, 2026
Merged

Fix: password signup shows JSON parse error when MAIL_URL is configured#10519
ArtyomSavchenko merged 1 commit intohcengineering:developfrom
spatialy:fix/signup-token-guard-10518

Conversation

@spatialy
Copy link
Contributor

Summary

Fixes #10518

When signing up with a password on deployments where MAIL_URL is configured, the account service returns token: undefined to enforce email confirmation. SignupForm.svelte was calling logIn() unconditionally — this triggered PUT /cookie with no Authorization header, the server returned 401 with an unparseable body, and the client crashed with "Unknown error: Unexpected token", leaving users stuck on the signup page even though their account was created successfully.

  • SignupForm.svelte: guard logIn() with result.token != null, matching the pattern already used in doLoginNavigate() in utils.ts
  • server/account-service/src/index.ts: fix PUT /cookie 401 response to use Koa's ctx.status/ctx.body instead of raw ctx.res.writeHead()/ctx.res.end(), so the JSON error body is correctly serialized
  • signupTokenGuard.test.ts: unit tests covering the token guard logic for all cases (undefined token, absent token, present token, null result)

Test plan

  • Deploy with MAIL_URL set to a real or dummy SMTP URL
  • Sign up with password ("Set Password Now") — should redirect to confirmation-sent page, no error
  • Verify PUT /cookie is not called in the network tab (token is undefined, so logIn() is skipped)
  • Deploy without MAIL_URL — sign up with password should still call logIn() and proceed to workspace selection as before
  • curl -X PUT http://localhost:3000/cookie → should return valid JSON {"error":{...}} with HTTP 401

@huly-github-staging
Copy link

Connected to Huly®: UBERF-15572

…onfigured

When signing up with a password on deployments with MAIL_URL set, the
account service returns token: undefined to enforce email confirmation.
SignupForm.svelte was calling logIn() unconditionally, which triggered
PUT /cookie without an Authorization header, returning a 401 with an
unparseable body and leaving the user stuck on the signup page.

- Guard logIn() in SignupForm.svelte with `result.token != null`, matching
  the pattern already used in doLoginNavigate() in utils.ts
- Fix PUT /cookie 401 response to use Koa's ctx.status/ctx.body instead of
  raw ctx.res.writeHead/end, so the error body is correctly serialized
- Add unit tests for the token guard logic

Fixes hcengineering#10518

Signed-off-by: Yulian Diaz <5605867+spatialy@users.noreply.github.com>
@spatialy spatialy force-pushed the fix/signup-token-guard-10518 branch from 5986161 to f685807 Compare February 17, 2026 21:15
@ArtyomSavchenko
Copy link
Member

@spatialy Thanks for your contribution

@ArtyomSavchenko ArtyomSavchenko merged commit f391dd0 into hcengineering:develop Feb 19, 2026
12 checks passed
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: Password signup shows "Unknown error: Unexpected token" when email service is configured

2 participants