Skip to content

fix(auth): add username field to RegisterScreen (#318) - #360

Merged
tilakpatel22 merged 1 commit into
Fincept-Corporation:mainfrom
akmalsyrf:fix/register-username-field-318
Jul 25, 2026
Merged

fix(auth): add username field to RegisterScreen (#318)#360
tilakpatel22 merged 1 commit into
Fincept-Corporation:mainfrom
akmalsyrf:fix/register-username-field-318

Conversation

@akmalsyrf

Copy link
Copy Markdown
Contributor

Summary

Closes #318

The Windows (and all-platform) signup form never exposed a USERNAME field, even though POST /user/register always requires one via RegisterRequest::username. The UI silently invented a username by concatenating first + last name:

QString username = auth::sanitize_input(fn + ln).toLower();

That caused several user-visible failures matching the report:

Failure mode Why it happens
Signup fails for common names John + Smithjohnsmith collides with an existing account
Confusing client-side error "Username must be 3-50 characters" appears with no username field on screen
Spaces / invalid characters Names like Mary Jane produce usernames with spaces that APIs reject
Opaque identity Users never choose or know the username stored for their account

This PR adds an explicit username input and wires it through the existing AuthManager::signup() / OTP-resend path. No AuthManager or AuthApi signature changes.

Scope note for maintainers

Per .github/CONTRIBUTING.md, PRs must link an issue labeled good-first-issue, help-wanted, or scope:approved. Issue #318 currently has type:bug + status:triage only.

Please add good-first-issue or scope:approved to #318 (or to this PR) so the scope gate clears. This is intentionally minimal and newcomer-sized: two files, one screen, one logical change.


Changes

RegisterScreen.h

  • Add username_lbl_ / username_ members alongside the other form fields.

RegisterScreen.cpp

  • Insert a USERNAME field after the first/last name row (before email).
  • Localize label + placeholder via retranslateUi() (tr("USERNAME"), tr("3-50 chars, letters/numbers/_")).
  • on_register():
    • Require username in the “all fields required” check.
    • Validate length 3–50.
    • Restrict to [a-z0-9_] after sanitize/lowercase (prevents the old space-from-name failure mode).
    • Pass the user-entered username to AuthManager::signup(...).
  • on_resend_otp() uses the same username field (no more name concatenation).
  • Clear username_ on successful OTP verification with the other fields.

First/last name fields are kept for UX continuity (they are still not sent to the API today — that is pre-existing and out of scope).


User-visible effect

Before: signup form = First / Last / Email / Phone / Password — username invented invisibly.
After: signup form includes USERNAME; the value the user types is what gets registered.


Test plan

  • Build fincept-qt on your platform (cmake --build --preset <os>-release or local equivalent).
  • Open Create Account from the auth stack.
  • Confirm a USERNAME field appears between name and email, with localized label/placeholder.
  • Submit with empty username → "All fields are required".
  • Submit username shorter than 3 chars → length error.
  • Submit username with spaces or symbols (e.g. john smith, john@x) → charset error.
  • Submit a valid unique username + other valid fields → proceeds to OTP page (or surfaces the real API error if the backend is down — unrelated to this UI fix).
  • On OTP page, Resend still uses the typed username (not first+last).
  • After successful OTP (when API is healthy), form fields including username are cleared.
  • Switch UI language and confirm USERNAME label/placeholder retranslate.

What I could / could not verify locally

I did not run a full Qt 6.8.3 app build or hit api.fincept.in end-to-end in this environment (upstream API TLS issues are tracked separately, e.g. #352). The change is UI-only against an already-correct signup(username, ...) API surface; logic was reviewed against AuthTypes.h / AuthManager::signup / AuthApi register error paths.


Out of scope (intentionally)

  • Backend / Cloudflare signup outages (HTTP 530, TLS on api.fincept.in).
  • Sending first/last name to the register API (API schema does not accept them today).
  • Async “username available” availability check.
  • Translation .ts / .qm updates for the new strings ( Linguist will pick them up on the next lupdate pass; English tr() sources are in place).

Made with Cursor

Signup was inventing usernames from first+last name with no visible field,
causing silent collisions and confusing validation errors. Collect username
explicitly and pass it through to AuthManager::signup / OTP resend.

Closes Fincept-Corporation#318

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

Hi @akmalsyrf — thanks for the PR!

Our automated scope gate flagged the following:

No scope-approved linked issue. This PR must close an issue that carries one of: good-first-issue, help-wanted, scope:approved. Link it in the PR body with Closes #NNN or via GitHub's "Linked issues" sidebar.

Please read CONTRIBUTING.md. Once an issue with the appropriate label exists and is linked here, re-run this check by pushing an empty commit or editing the PR description. A maintainer can also bypass this gate by adding the scope:approved label to this PR.

PRs that remain unresolved for 7 days will be closed automatically.

@github-actions github-actions Bot added the needs-scope-approval Auto-applied by pr-gate.yml to PRs that fail the scope gate. label Jul 20, 2026
@tilakpatel22

Copy link
Copy Markdown
Collaborator

@akmalsyrf Thanks for the PR !!

@tilakpatel22
tilakpatel22 merged commit 41ee551 into Fincept-Corporation:main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-scope-approval Auto-applied by pr-gate.yml to PRs that fail the scope gate.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Sign up bug in window application

2 participants