Skip to content

Conversation

@swittk
Copy link

@swittk swittk commented Oct 7, 2025

Pull Request

Issue

Closes: #9560

Approach

  • Optional autoSignupOnLogin boolean flag for Parse-server configuration
  • A retry try/catch wrapper around login to support the new flag, creating a signup user only when the flag is true & conditions are met.

Tasks

  • Add tests

Summary by CodeRabbit

  • New Features

    • Optional auto-signup on login: when enabled, a missing-user login with valid credentials will create the user and complete login.
  • Configuration

    • New option autoSignupOnLogin (default: false). Can be set via environment/config.
  • Documentation

    • Public docs and types updated to include autoSignupOnLogin.
  • Tests

    • Added tests to validate automatic user creation and successful login when enabled.

✏️ Tip: You can customize this high-level summary in your review settings.

@parse-github-assistant
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: added autosignuponlogin feat: Added autosignuponlogin Oct 7, 2025
@parse-github-assistant
Copy link

🚀 Thanks for opening this pull request!

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Oct 7, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

📝 Walkthrough

Walkthrough

Adds a new server option autoSignupOnLogin, wires it into config, options, docs and typings, updates UsersRouter to automatically create a user on login-if-not-found, and adds tests (including a duplicated test block) and validation for the new option.

Changes

Cohort / File(s) Summary
Tests: Auto-signup on login
spec/ParseUser.spec.js
Adds a test "auto signs up user on login when enabled" that enables autoSignupOnLogin, performs REST login for a new username/password, asserts returned username and sessionToken, verifies login via Parse.User.logIn, then resets config. The test block is added twice (duplicate).
Config validation
src/Config.js
Adds autoSignupOnLogin to options validation: introduces validateAutoSignupOnLogin and calls it from validateOptions.
Options definitions and docs
src/Options/Definitions.js, src/Options/docs.js, src/Options/index.js
Adds public option autoSignupOnLogin (PARSE_SERVER_AUTO_SIGNUP_ON_LOGIN, boolean, default false) to definitions and docs; also exposes emailVerifyTokenValidityDuration in index.js.
Login flow: auto-signup
src/Routers/UsersRouter.js
Extends handleLogIn to attempt auto-signup on OBJECT_NOT_FOUND when enabled: adds helpers _getLoginPayload, _prepareAutoSignupCredentials, _autoSignupOnLogin; creates temporary signup session, retries authentication, and attempts cleanup of the temp session token.
Type definitions
types/Options/index.d.ts
Adds optional boolean autoSignupOnLogin?: boolean to ParseServerOptions typings.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant UR as UsersRouter
  participant AU as AuthService
  participant UC as UserCreate
  participant SS as Sessions

  C->>UR: POST /login {username/email, password}
  UR->>AU: authenticate(credentials)
  AU-->>UR: Error OBJECT_NOT_FOUND
  alt autoSignupOnLogin enabled & username/password present
    UR->>UC: createUser(minimalCredentials)
    UC-->>UR: {userId, tempSessionToken}
    UR->>AU: authenticate(credentials)  -- retry after signup
    AU-->>UR: {sessionToken, user}
    UR->>SS: revoke(tempSessionToken)  -- best-effort cleanup
    SS-->>UR: OK / NOT_FOUND
    UR-->>C: 200 {sessionToken, user}
  else disabled or missing credentials
    UR-->>C: Error OBJECT_NOT_FOUND
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Review UsersRouter changes carefully: new control flow, race conditions, and cleanup of temporary signup session token.
  • Confirm security/validation in _prepareAutoSignupCredentials to avoid unintended auto-creation (authData checks, email vs username handling).
  • Verify tests: duplicated test block should be deduplicated or justified.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Added autosignuponlogin' is specific to the feature being added and accurately describes the primary change in the changeset.
Description check ✅ Passed The description includes the required Issue section with a linked issue, an Approach section explaining the changes, and marks the tasks checkbox. However, it lacks explicit mention of documentation updates and security checks that the template indicates as important.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #9560: an optional autoSignupOnLogin flag that creates users on login when no matching user exists. Configuration, validation, routing logic, tests, and type definitions have been added.
Out of Scope Changes check ✅ Passed All changes are scoped to the autoSignupOnLogin feature as specified in issue #9560. The addition of emailVerifyTokenValidityDuration in Options/index.js appears incidental but does not conflict with the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.40.0)
spec/ParseUser.spec.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
spec/ParseUser.spec.js (1)

189-213: Always restore server config; use try/finally to prevent leakage

If an assertion throws before the last lines, autoSignupOnLogin may remain enabled and affect other tests.

Apply try/finally so logout and config reset always run.

 it('auto signs up user on login when enabled', async () => {
-  await reconfigureServer({ autoSignupOnLogin: true });
-  const username = 'autoLoginUser';
-  const password = 'autoLoginPass';
-  const response = await request({
-    method: 'POST',
-    url: 'http://localhost:8378/1/login',
-    headers: {
-      'X-Parse-Application-Id': Parse.applicationId,
-      'X-Parse-REST-API-Key': 'rest',
-      'Content-Type': 'application/json',
-    },
-    body: {
-      username,
-      password,
-    },
-  });
-  expect(response.data.username).toBe(username);
-  expect(response.data.sessionToken).toBeDefined();
-
-  const user = await Parse.User.logIn(username, password);
-  expect(user).toBeDefined();
-  await Parse.User.logOut();
-  await reconfigureServer({ autoSignupOnLogin: false });
+  await reconfigureServer({ autoSignupOnLogin: true });
+  const username = 'autoLoginUser';
+  const password = 'autoLoginPass';
+  try {
+    const response = await request({
+      method: 'POST',
+      url: 'http://localhost:8378/1/login',
+      headers: {
+        'X-Parse-Application-Id': Parse.applicationId,
+        'X-Parse-REST-API-Key': 'rest',
+        'Content-Type': 'application/json',
+      },
+      body: { username, password },
+    });
+    expect(response.data.username).toBe(username);
+    expect(response.data.sessionToken).toBeDefined();
+    const user = await Parse.User.logIn(username, password);
+    expect(user).toBeDefined();
+  } finally {
+    await Parse.User.logOut().catch(() => {});
+    await reconfigureServer({ autoSignupOnLogin: false });
+  }
 });
src/Routers/UsersRouter.js (3)

366-393: Gate auto-signup strictly and align normalization

  • Don’t auto-signup if a user with provided username/email exists; avoids enumeration on wrong password.
  • Avoid trimming here unless authentication does the same; differing normalization can create unintended accounts.

Apply the following changes (make function async, add existence check, remove trim):

-  _prepareAutoSignupCredentials(req, error) {
+  async _prepareAutoSignupCredentials(req, error) {
     if (!req.config.autoSignupOnLogin) {
       return null;
     }
     if (!(error instanceof Parse.Error) || error.code !== Parse.Error.OBJECT_NOT_FOUND) {
       return null;
     }
     if (req.body && req.body.authData) {
       return null;
     }
     const payload = this._getLoginPayload(req);
-    const rawUsername = typeof payload.username === 'string' ? payload.username.trim() : '';
-    const rawEmail = typeof payload.email === 'string' ? payload.email.trim() : '';
-    const password = payload.password;
-    const hasUsername = rawUsername.length > 0;
-    const hasEmail = rawEmail.length > 0;
+    const rawUsername = typeof payload.username === 'string' ? payload.username : '';
+    const rawEmail = typeof payload.email === 'string' ? payload.email : '';
+    const password = payload.password;
+    const hasUsername = rawUsername.length > 0;
+    const hasEmail = rawEmail.length > 0;
     if (!hasUsername && !hasEmail) {
       return null;
     }
     if (typeof password !== 'string') {
       return null;
     }
+    // Only auto-signup when there is no existing user for supplied identifier(s)
+    let query;
+    if (hasEmail && hasUsername) {
+      query = { email: rawEmail, username: rawUsername };
+    } else if (hasEmail) {
+      query = { email: rawEmail };
+    } else {
+      query = { $or: [{ username: rawUsername }, { email: rawUsername }] };
+    }
+    const existing = await req.config.database.find('_User', query, {}, Auth.maintenance(req.config));
+    if (existing && existing.length) {
+      return null;
+    }
     return {
       username: hasUsername ? rawUsername : rawEmail,
       email: hasEmail ? rawEmail : undefined,
       password,
     };
   }

395-422: Handle duplicate username/email errors gracefully to avoid race-induced failures

If another request created the user between your existence check and create, rest.create will throw USERNAME_TAKEN / EMAIL_TAKEN. Swallow these and continue to re-authenticate.

Apply:

   async _autoSignupOnLogin(req, credentials) {
     const userData = {
       username: credentials.username,
       password: credentials.password,
     };
     if (credentials.email !== undefined) {
       userData.email = credentials.email;
     }
@@
-    const result = await rest.create(
-      req.config,
-      req.auth,
-      '_User',
-      userData,
-      req.info.clientSDK,
-      req.info.context
-    );
-    const user = result?.response;
-    if (!user) {
-      throw new Parse.Error(
-        Parse.Error.INTERNAL_SERVER_ERROR,
-        'Unable to automatically sign up user.'
-      );
-    }
-    return user.sessionToken;
+    try {
+      const result = await rest.create(
+        req.config,
+        req.auth,
+        '_User',
+        userData,
+        req.info.clientSDK,
+        req.info.context
+      );
+      const user = result?.response;
+      if (!user) {
+        throw new Parse.Error(
+          Parse.Error.INTERNAL_SERVER_ERROR,
+          'Unable to automatically sign up user.'
+        );
+      }
+      return user.sessionToken;
+    } catch (e) {
+      if (e && (e.code === Parse.Error.USERNAME_TAKEN || e.code === Parse.Error.EMAIL_TAKEN)) {
+        // Likely created concurrently; let caller re-attempt authentication
+        return null;
+      }
+      throw e;
+    }
   }

377-382: Normalization mismatch (trim) may create unintended accounts

Login authentication doesn’t trim username/email, but auto-signup does. This can auto-create “foo@example.com” when the user typed “ foo@example.com ”.

Remove trim here (or apply consistent normalization across both paths). See suggested diff in the comment above for Lines 366-393.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be362fe and 486a405.

📒 Files selected for processing (7)
  • spec/ParseUser.spec.js (1 hunks)
  • src/Config.js (3 hunks)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • src/Routers/UsersRouter.js (3 hunks)
  • types/Options/index.d.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/Options/Definitions.js (1)
resources/buildConfigDefinitions.js (1)
  • parsers (12-12)
spec/ParseUser.spec.js (1)
spec/helper.js (2)
  • reconfigureServer (171-205)
  • Parse (4-4)
🪛 Biome (2.1.2)
src/Options/index.js

[error] 197-197: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

🔇 Additional comments (4)
src/Options/index.js (1)

193-197: Option surfaced correctly; verify Biome parse error on Line 197

The field and docs look consistent with the surrounding Flow types. However, static analysis flagged “Expected a statement but instead found ‘?’” at Line 197; likely a parser/config hiccup or stray char.

  • Please re-run lint/format locally and ensure Biome/ESLint parse this file cleanly.
  • If needed, regenerate options or normalize the line to remove hidden chars.
types/Options/index.d.ts (1)

80-80: Types aligned

autoSignupOnLogin?: boolean matches the public option surface.

src/Options/docs.js (1)

89-89: Docs added and consistent

JSDoc for autoSignupOnLogin matches Definitions/help and default.

src/Options/Definitions.js (1)

485-491: Definition looks good

Env, help, parser, and default for autoSignupOnLogin are correct and aligned with the option surface.

@swittk
Copy link
Author

swittk commented Oct 9, 2025

any more changes needed?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Routers/UsersRouter.js (1)

365-378: Consider extracting shared payload logic.

This method duplicates the query/body fallback logic from _authenticateUserFromRequest (lines 71-77). While the duplication is minimal, extracting this shared logic into _getLoginPayload and calling it from both methods would improve maintainability.

Optional refactor:

Reuse _getLoginPayload in _authenticateUserFromRequest:

 _authenticateUserFromRequest(req) {
   return new Promise((resolve, reject) => {
-    // Use query parameters instead if provided in url
-    let payload = req.body || {};
-    if (
-      (!payload.username && req.query && req.query.username) ||
-      (!payload.email && req.query && req.query.email)
-    ) {
-      payload = req.query;
-    }
-    const { username, email, password, ignoreEmailVerification } = payload;
+    const payload = this._getLoginPayload(req);
+    const { username, email, password } = payload;
+    const ignoreEmailVerification = (req.body || req.query)?.ignoreEmailVerification;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 486a405 and b8aeaa0.

📒 Files selected for processing (1)
  • src/Routers/UsersRouter.js (4 hunks)
🔇 Additional comments (4)
src/Routers/UsersRouter.js (4)

203-245: Implementation addresses race condition and enumeration concerns.

The current implementation successfully handles the concerns raised in previous reviews:

  1. Race condition (lines 217-228): Catches duplicate-user errors during signup and re-authenticates, allowing concurrent login requests to succeed when another request creates the user first.
  2. User enumeration: By re-authenticating on USERNAME_TAKEN/EMAIL_TAKEN errors, wrong-password scenarios correctly return OBJECT_NOT_FOUND (matching standard login behavior) rather than leaking account existence.
  3. Session cleanup (lines 229-239): Properly destroys the temporary signup session token with appropriate error handling.

The implementation aligns well with the discussion in past reviews.


383-410: LGTM!

The guard conditions and credential preparation logic are well-structured:

  • Comprehensive checks ensure auto-signup only proceeds when appropriate (feature enabled, OBJECT_NOT_FOUND error, no authData, valid credentials).
  • Proper trimming and validation of username and email fields.
  • Correctly handles the case where only email is provided by using it as the username (line 406), ensuring the username field is always populated for user creation.

412-439: LGTM!

The implementation correctly delegates to rest.create, ensuring all existing validation, triggers, schema checks, and side effects are executed. The error handling properly covers the edge case where user creation might succeed but not return a user object.


744-744: LGTM!

Standardizing error serialization with JSON.stringify improves consistency in error logging.

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: potential security breach, it's uncommon to signup a user by email without validating his email, this feature can expose a breach or will be useless in common production app.

the approach should be inverted and like "autoLoginOnSignup", i you provided the correct email/username and password to the login endpoint, you login the user, otherwise you try to signup and then return error code if email validation for example is needed.

Also i don't know how the server SDK, all libs will react by returning a email validation sent on the login endpoint

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: if this feature is merged like this, i strongly suggest to add tests to covering edges cases and email validation/user account creation are not bypassed

@mtrezza
Copy link
Member

mtrezza commented Oct 14, 2025

it's uncommon to signup a user by email without validating his email, this feature can expose a breach or will be useless in common production app.

That should not be possible. If validation is needed, then the login endpoint should return the same response as the the sign-up endpoint would.

the approach should be inverted and like "autoLoginOnSignup", i you provided the correct email/username and password to the login endpoint, you login the user, otherwise you try to signup and then return error code if email validation for example is needed.

What's the difference? If we extend /login then we add sign-up before the existing code, if we extend /signup then we add login after existing code. In either case the endpoint needs to extend its response specs.

i strongly suggest to add tests to covering edges cases and email validation/user account creation are not bypassed

Good point; it seems more tests need to be added before merging.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8aeaa0 and ebc9a64.

📒 Files selected for processing (7)
  • spec/ParseUser.spec.js (1 hunks)
  • src/Config.js (3 hunks)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • src/Routers/UsersRouter.js (4 hunks)
  • types/Options/index.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • types/Options/index.d.ts
  • src/Options/Definitions.js
  • spec/ParseUser.spec.js
  • src/Options/docs.js
  • src/Config.js
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-17T15:02:48.786Z
Learning: For Parse Server PRs, always suggest an Angular commit convention PR title that would make a meaningful changelog entry for developers. Update the PR title suggestion on every commit. The format should be: type(scope): description. Common types include feat, fix, perf, refactor, docs, test, chore. The scope should identify the subsystem (e.g., graphql, rest, push, security). The description should be action-oriented and clearly convey the change's impact to developers.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.
📚 Learning: 2025-11-08T13:46:04.940Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.

Applied to files:

  • src/Routers/UsersRouter.js
  • src/Options/index.js
📚 Learning: 2025-11-08T13:46:04.940Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.

Applied to files:

  • src/Options/index.js
📚 Learning: 2025-12-02T06:55:53.808Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-12-02T06:55:53.808Z
Learning: When reviewing Parse Server PRs that add or modify Parse Server options, always verify that changes are properly reflected in three files: src/Options/index.js (where changes originate), src/Options/Definitions.js, and src/Options/docs.js. The correct workflow is: make changes in index.js first, then run `npm run definitions` to automatically replicate the changes to Definitions.js and docs.js.

Applied to files:

  • src/Options/index.js
🪛 Biome (2.1.2)
src/Options/index.js

[error] 196-196: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Node 22
  • GitHub Check: Check Types
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Redis Cache
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Node 20
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: Node 18
  • GitHub Check: Benchmarks
🔇 Additional comments (5)
src/Routers/UsersRouter.js (4)

205-247: Race condition and session cleanup properly handled.

The implementation correctly addresses:

  • Race conditions by catching duplicate errors (lines 223-226) and re-authenticating
  • Temporary session cleanup (lines 231-241) with proper error handling
  • Consistent error behavior by ensuring wrong passwords return OBJECT_NOT_FOUND

However, note that the fundamental design concerns raised by the maintainer in the PR comments remain: whether auto-signup-on-login is the right approach vs. auto-login-on-signup, and whether email verification requirements are being properly enforced throughout this flow.

Based on PR comments from the maintainer.


367-380: LGTM - Good refactoring.

This helper consolidates the credential extraction logic used in multiple places, reducing duplication and improving maintainability.


788-788: LGTM - Improved error logging.

Using JSON.stringify(e) ensures all error properties are captured in logs, improving observability for debugging authentication failures.


414-441: Verify that rest.create enforces all signup policies including preventSignupWithUnverifiedEmail and verifyUserEmails.

The implementation delegates to rest.create for user creation, which should apply existing validation logic. However, manual verification is needed to confirm that email verification policies are properly enforced when rest.create is called in the auto-signup context, particularly to ensure preventSignupWithUnverifiedEmail and verifyUserEmails settings are respected.

src/Options/index.js (1)

196-200: Verify email verification enforcement during auto-signup flow.

Ensure that when autoSignupOnLogin is enabled, all email verification requirements are applied—specifically that preventSignupWithUnverifiedEmail and verifyUserEmails settings are enforced during the auto-signup process, just as they are during normal signup.

Additionally, consider the maintainer's suggestion to evaluate an alternative approach: implementing "autoLoginOnSignup" where the signup endpoint handles both signup and login in a single request, rather than modifying the login endpoint to create users.

Comment on lines +407 to +410
return {
username: hasUsername ? rawUsername : rawEmail,
email: hasEmail ? rawEmail : undefined,
password,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Consider validation implications of username fallback to email.

When only an email is provided (line 408), the username is set to the email address. This could cause issues:

  • Email format may not meet username validation requirements (e.g., special characters, length limits)
  • Could conflict with existing usernames if someone's username happens to match another user's email
  • May be unexpected behavior for users

Verify that this approach is validated correctly:

#!/bin/bash
# Check username validation rules that might conflict with email format
rg -n -C3 'username.*validation|validateUsername' --type=js

Consider requiring an explicit username for auto-signup, or document this behavior clearly in the option description.

🤖 Prompt for AI Agents
In src/Routers/UsersRouter.js around lines 407 to 410, the code falls back to
using the raw email as the username which can violate username validation rules
and create uniqueness/conflict issues; update the signup flow so that when
username is derived from email you (a) run the same username validation routine
(validateUsername/username validation rules) against the email-derived username
and reject the request with a clear error if it fails, or (b) instead require an
explicit username for auto-signup (document this option), or (c) if you prefer
auto-generation, create a sanitized/normalized username from the email (strip
invalid chars, enforce length) then check DB uniqueness and resolve collisions
(append numeric suffix) before saving; implement one of these fixes and ensure
the error path returns a descriptive message and the DB uniqueness check is
performed prior to persisting.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 74.00000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.50%. Comparing base (e78e58d) to head (ebc9a64).

Files with missing lines Patch % Lines
src/Routers/UsersRouter.js 74.46% 12 Missing ⚠️
src/Config.js 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9873      +/-   ##
==========================================
- Coverage   92.56%   92.50%   -0.07%     
==========================================
  Files         191      191              
  Lines       15544    15592      +48     
  Branches      177      177              
==========================================
+ Hits        14389    14424      +35     
- Misses       1143     1156      +13     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtrezza
Copy link
Member

mtrezza commented Dec 5, 2025

@Moumouls Just a ping so we can continue with this PR; there are some open questions.

@mtrezza
Copy link
Member

mtrezza commented Dec 5, 2025

@swittk are you still willing to work on this PR?

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.

Add Parse Server option autoSignupOnLogin to automatically create a user on log-in if none exists

4 participants