Skip to content

fix(auth): trim anonymous registration usernames - #163

Closed
aiirvizionz wants to merge 1 commit into
profullstack:masterfrom
aiirvizionz:clientkit/register-anon-trim-username
Closed

fix(auth): trim anonymous registration usernames#163
aiirvizionz wants to merge 1 commit into
profullstack:masterfrom
aiirvizionz:clientkit/register-anon-trim-username

Conversation

@aiirvizionz

Copy link
Copy Markdown
Contributor

Summary

  • Trim anonymous registration usernames before duplicate checks and insert
  • Trim display names and fall back to the cleaned username when blank
  • Reject whitespace-only usernames before touching auth/session validation

Why

Anonymous invite registration accepted raw username strings. A value like alice could be stored with leading/trailing spaces, and a whitespace-only username could get past the basic truthiness check. That makes account display and duplicate detection less reliable.

Validation

  • node --check src/app/api/auth/register-anon/route.js
  • node --check src/app/api/auth/register-anon/route.test.js
  • git diff --check

Note: node_modules/.bin/vitest.cmd run src/app/api/auth/register-anon/route.test.js still fails before test collection because this repo's Vitest config loads @vitejs/plugin-react against a Vite build that does not export ./internal under the current Windows/Node runtime. The focused regression test is included for CI once the project runner resolves normally.

return NextResponse.json({ error: 'Invite token is required' }, { status: 400 });
}
if (!username || typeof username !== 'string') {
if (!cleanUsername) {
@ralyodio ralyodio closed this Jul 30, 2026
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.

3 participants