Refine and Standardize Username Constraints#4828
Conversation
… rules with a centralized USERNAME_REQUIREMENTS_TEXT for better maintainability.
…tion | Replace hardcoded username requirements with localized strings in user modals
timothycarambat
left a comment
There was a problem hiding this comment.
We need some cleanup on some UI pages.
Account modal
If i attempt to submit a bad name i get a generic "Internal server" error message in toast. It should surface the real error or enforce the pattern native HTML Validator message.
this seems to be the only page showing a bad error message. All other UIs report the real error with an invalid username
…sibilities on the server | Allow onboarding flow multi-user mode username creation step to send pre-validated credentials to server.
@timothycarambat Can you clarify what the "Account Modal" is? In
Same goes for the Edit User modal:
|
Enable multi-user mode and click on the top-right user pfp icon to open the "settings" modal. |
…se with error details instead of a plain status for internal server errors.
…p components to use centralized translation key.
Fix in f8c1f02 |
|
New Translations PR: |
…809-standardize-username-constraints
allow users to keep existing usernames without collision
* normalize translations * add translations --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
* Update common.js (#4894) * Update common.js Added missing translations in Dutch. * linting --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Add keyboard shortcuts to scroll to top and bottom of chat history (#4870) * Add keybindings to scroll to top and bottom of chat history * fix isUserScrolling flag and set scrollToBottom to be instant instead of smoothe * fix stream scroll * fix default export by removing unneeded constant * Replace file-defined `isMac` variable with global util * extract funcitonality to hooks for clarity * patch import --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * 4825 patch yt file collector api (#4904) Patch YT links in API document collector closes #4825 * Refine and Standardize Username Constraints (#4828) * Implement Unix username standard validations on username creation and updating. * Remove leading underscore permissibility | Replace hardcoded username rules with a centralized USERNAME_REQUIREMENTS_TEXT for better maintainability. * Add username requirements translations for invite and admin user creation | Replace hardcoded username requirements with localized strings in user modals * Refactor username requirements localization * Remove unneeded comment | Move Regex comment to validator fn * Remove username validation utility function to keep validation responsibilities on the server | Allow onboarding flow multi-user mode username creation step to send pre-validated credentials to server. * Enhance error handling in system endpoints by returning a JSON response with error details instead of a plain status for internal server errors. * Update username requirement localization in AccountModal and UserSetup components to use centralized translation key. * test enforcements allow users to keep existing usernames without collision * Normalize Translations (#4861) * normalize translations * add translations --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * New login page UI (#4862) * wip new home page multiuser auth * implement new login page designs for single and multiuser auth * fix scroll overflow on mobile * rounded custom logos * fix up translation entry to use var --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * [Chore] Autotranslation tool using DMR (#4907) * update translations + DMR loading * updates to misspellings * Persist Ollama context preferences in LC tools (#4908) * Persist Ollama context preferences in LC tools * remove comment * Refactor Ollama context window setting (#4909) * fix log line * resolves #4913, remove non-const vars * Patch AzureOpenAI tool calling from `function` to `tool` (#4922) * Thinking block persist toggle state (#4916) * Thinking block persist toggle state * dev build * Manage Onboarding decision via DB flag (#4926) * WIP add onboarding flag to db * dev build * fix onboarding telem call * Fix sidebar thread layer (#4881) * fixed sidebar overlay + overflow behavior * ran yarn lint * fixed footer vertical reserved space * linting --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Toggle switch component (#4890) * replace all toggle switches with toggle component * add variant, label, and description support for toggle component * refactor Toggle with subcomponents and JSDoc * use checked value from Toggle onChange callback * replace missed inline toggles with Toggle component * fix jsdoc to use optional props --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Fix: Clean username already exists error (#4914) * Add Prisma unique constraint error messaging. * Create `_identifyErrorAndFormatMessage` private method for identifying the error type and returning the approprioate error message string * fix: prevent Citations UI glitching during streaming chats (#4897) * fix: prevent Citations UI glitching during streaming chats * replaced random keys with stable keys * simplify citation glitch fix * Remove unneeded memo() * Simplify key logic * Replace Boolean(source) with !!source * change cohere to behave with citations like other models --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> Co-authored-by: Marcello Fitton <macfittondev@gmail.com> * fix tooltip generic name * Support PrivateModeAI Integration (#4937) * Support PrivateModeAI Integration * tooltip for proxy * feat: Add ability to edit existing SQL agent connections (#4848) * Add the ability to edit existing SQL connections * Enhance SQL connection management by adding connections prop to DBConnection and SQLConnectionModal components for improved duplicate detection and handling. * format * fix: prevent input defocus in SQL connection edit modal Fixed an issue where typing in input fields would cause the field to lose focus during editing. The useEffect dependency array was using the entire existingConnection object, which could change reference on parent re-renders, triggering unnecessary re-fetches and unmounting form inputs. Changed the dependency to use the primitive database_id value instead of the object reference, ensuring the effect only runs when the actual connection being edited changes. * fix: prevent duplicate SQL connections from being created Fixed an issue where saving SQL connections multiple times would create duplicate entries with auto-generated hash suffixes (e.g., my-db-abc7). This occurred because the frontend maintained stale action properties on connections after saves, causing the backend to treat already-saved connections as new additions. Backend changes (server/models/systemSettings.js): - Modified mergeConnections to skip action:add items that already exist - Reject duplicate updates instead of auto-renaming with UUID suffixes - Check if original connection exists before applying updates Frontend changes: - Added hasChanges prop to SQL connector component - Automatically refresh connections from backend after successful save - Ensures local state has clean data without stale action properties This prevents the creation of confusing duplicate entries and ensures only the connections the user explicitly created are stored. * Refactor to use existing system settings endpoint for getting agent SQL connections | Add better documentation * Simplify handleUpdateConnection handler * refactor mergeConnections to use map * remove console log * fix bug where edit SQL connection modal values werent recomputed after re-opening * Add loading state for fetching agent SQL connections * tooltip * remove unused import * Put skip conditions in switch statement * throw error if default switch case is triggered --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * fix rerender for loading promptReply resolves #4938 * Fix double scroll container in agent flow builder (#4933) * fix double scroll container in agent flow builder * use overflow-clip to prevent focus events from scrolling outer container * add bottom padding --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * feat: Enable essential ESLint rules and refactor frontend lint config (#4923) * Install eslint-plugin-unsued-imports * Refactor eslint to a sane working config * enable jsx-no-target-blank | disable no-escaped-entities * disable react/display-name react-hooks/immutability and react-hooks/preserve-manual-memoization * chore: remove unused imports (#4925) remove unused imports * fix: resolve react-hooks ESLint errors (#4929) fix react-hooks linting errors * fix: add rel=noreferrer to target=_blank links (#4928) Fix no target blank errors * fix: resolve undefined variable errors in frontend (#4927) * delete unused file src/components/DataConnectorOption/index.jsx * fix undefined errors * chore: Remove unused variables in frontend (#4924) Remove unused variables --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * lint applied by fixer * simplify tooltips for prompt input items Remove container for images * SambaNova Integration (#4943) * SambaNova Integration * lint * Update LMStudio LLM & Embedder for API token (#4948) - Updates Option panels to be consistent for other providers adds API key to all LMStudio API calls * Web push notifications (#4942) * WIP push notifications * testing push * cleanup for web-push bootstrapping * Fix agent workspace settings loading forever (#4956) remove .brief from SystemSettings.agent_sql_connections * patch warning * patch translator * VN patch for lang/ISO name * fix legacy toggle on confluence page * add provider field to chats (#4959) * make translator placeholder aware * fix bad arabic placeholder that got translated * add provider to map * UAE region support for bedrock models (#4964) * added me-central-1 to bedrock regions * fixed long region name * fix: scroll active sidebar items into view (#4965) * Add centering of settings sidebar link when isActive * abstract redundant logic into a reusable hook * add jsdocs | refactor hook to consume behavior and block args * remove unused import * dev --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * remove deprecated value for Google embedding * linting + tolerate folder deletion for bad ParsedFile inserts * refactor: Migrate system preferences to field-based endpoint and remove deprecated endpoint (#4958) * Migrate all existing deprecated system preferences endpoint services to new service by field | delete old endpoint and service * format * destructure settings from response * nitpick --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Refactor: Remove redundant message state sync in ChatContainer (#4941) * remove redundant message state sync in ChatContainer * small lint --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * chore: bump ollama SDK from 0.5.10 to 0.6.3 (#4977) upgrade ollama in server to latest (0.6.3) * set embedder output dimensions for LocalAI and Gemini (gemini-embedding-001) (#4980) * Fix Sidebar Clipping When Closed (#4970) fix sidebar clipping when closed * add QA image build for GCHR images * fix GH action color escape * update cleanup to assume repo name * fix build tag lowercase org name * normalize logo wordmark * fix logo jump resolves #4993 * patch out max_tokens from block output amount resolves #3421 * fix: correct TPS calculation for Generic OpenAI provider with llama.cpp (#4981) * add check for timings field on final chunk to override usage data * refactor: extract llama.cpp timings into reusable private method Move timings extraction into #extractTimings so it can be shared by both streaming (handleStream) and non-streaming (getChatCompletion) code paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * lint and cleanup --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * add support for custom headers for LLM Generic OpenAI (#4999) * add support for custom headers for LLM Generic OpenAI * add env * patch out no finish reason from microsoft/Foundry-Local#423 * 1.11.0 release tag * update pg tag --------- Co-authored-by: j0rDy <jkersten84@hotmail.com> Co-authored-by: Marcello Fitton <106866560+angelplusultra@users.noreply.github.com> Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Colin Perry <55003831+17ColinMiPerry@users.noreply.github.com> Co-authored-by: Neha Prasad <neh6a683@gmail.com> Co-authored-by: Marcello Fitton <macfittondev@gmail.com> Co-authored-by: vigorous-ride <68917684+vigorous-ride@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Update common.js (#4894) * Update common.js Added missing translations in Dutch. * linting --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Add keyboard shortcuts to scroll to top and bottom of chat history (#4870) * Add keybindings to scroll to top and bottom of chat history * fix isUserScrolling flag and set scrollToBottom to be instant instead of smoothe * fix stream scroll * fix default export by removing unneeded constant * Replace file-defined `isMac` variable with global util * extract funcitonality to hooks for clarity * patch import --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * 4825 patch yt file collector api (#4904) Patch YT links in API document collector closes #4825 * Refine and Standardize Username Constraints (#4828) * Implement Unix username standard validations on username creation and updating. * Remove leading underscore permissibility | Replace hardcoded username rules with a centralized USERNAME_REQUIREMENTS_TEXT for better maintainability. * Add username requirements translations for invite and admin user creation | Replace hardcoded username requirements with localized strings in user modals * Refactor username requirements localization * Remove unneeded comment | Move Regex comment to validator fn * Remove username validation utility function to keep validation responsibilities on the server | Allow onboarding flow multi-user mode username creation step to send pre-validated credentials to server. * Enhance error handling in system endpoints by returning a JSON response with error details instead of a plain status for internal server errors. * Update username requirement localization in AccountModal and UserSetup components to use centralized translation key. * test enforcements allow users to keep existing usernames without collision * Normalize Translations (#4861) * normalize translations * add translations --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * New login page UI (#4862) * wip new home page multiuser auth * implement new login page designs for single and multiuser auth * fix scroll overflow on mobile * rounded custom logos * fix up translation entry to use var --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * [Chore] Autotranslation tool using DMR (#4907) * update translations + DMR loading * updates to misspellings * Persist Ollama context preferences in LC tools (#4908) * Persist Ollama context preferences in LC tools * remove comment * Refactor Ollama context window setting (#4909) * fix log line * resolves #4913, remove non-const vars * Patch AzureOpenAI tool calling from `function` to `tool` (#4922) * Thinking block persist toggle state (#4916) * Thinking block persist toggle state * dev build * Manage Onboarding decision via DB flag (#4926) * WIP add onboarding flag to db * dev build * fix onboarding telem call * Fix sidebar thread layer (#4881) * fixed sidebar overlay + overflow behavior * ran yarn lint * fixed footer vertical reserved space * linting --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Toggle switch component (#4890) * replace all toggle switches with toggle component * add variant, label, and description support for toggle component * refactor Toggle with subcomponents and JSDoc * use checked value from Toggle onChange callback * replace missed inline toggles with Toggle component * fix jsdoc to use optional props --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Fix: Clean username already exists error (#4914) * Add Prisma unique constraint error messaging. * Create `_identifyErrorAndFormatMessage` private method for identifying the error type and returning the approprioate error message string * fix: prevent Citations UI glitching during streaming chats (#4897) * fix: prevent Citations UI glitching during streaming chats * replaced random keys with stable keys * simplify citation glitch fix * Remove unneeded memo() * Simplify key logic * Replace Boolean(source) with !!source * change cohere to behave with citations like other models --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> Co-authored-by: Marcello Fitton <macfittondev@gmail.com> * fix tooltip generic name * Support PrivateModeAI Integration (#4937) * Support PrivateModeAI Integration * tooltip for proxy * feat: Add ability to edit existing SQL agent connections (#4848) * Add the ability to edit existing SQL connections * Enhance SQL connection management by adding connections prop to DBConnection and SQLConnectionModal components for improved duplicate detection and handling. * format * fix: prevent input defocus in SQL connection edit modal Fixed an issue where typing in input fields would cause the field to lose focus during editing. The useEffect dependency array was using the entire existingConnection object, which could change reference on parent re-renders, triggering unnecessary re-fetches and unmounting form inputs. Changed the dependency to use the primitive database_id value instead of the object reference, ensuring the effect only runs when the actual connection being edited changes. * fix: prevent duplicate SQL connections from being created Fixed an issue where saving SQL connections multiple times would create duplicate entries with auto-generated hash suffixes (e.g., my-db-abc7). This occurred because the frontend maintained stale action properties on connections after saves, causing the backend to treat already-saved connections as new additions. Backend changes (server/models/systemSettings.js): - Modified mergeConnections to skip action:add items that already exist - Reject duplicate updates instead of auto-renaming with UUID suffixes - Check if original connection exists before applying updates Frontend changes: - Added hasChanges prop to SQL connector component - Automatically refresh connections from backend after successful save - Ensures local state has clean data without stale action properties This prevents the creation of confusing duplicate entries and ensures only the connections the user explicitly created are stored. * Refactor to use existing system settings endpoint for getting agent SQL connections | Add better documentation * Simplify handleUpdateConnection handler * refactor mergeConnections to use map * remove console log * fix bug where edit SQL connection modal values werent recomputed after re-opening * Add loading state for fetching agent SQL connections * tooltip * remove unused import * Put skip conditions in switch statement * throw error if default switch case is triggered --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * fix rerender for loading promptReply resolves #4938 * Fix double scroll container in agent flow builder (#4933) * fix double scroll container in agent flow builder * use overflow-clip to prevent focus events from scrolling outer container * add bottom padding --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * feat: Enable essential ESLint rules and refactor frontend lint config (#4923) * Install eslint-plugin-unsued-imports * Refactor eslint to a sane working config * enable jsx-no-target-blank | disable no-escaped-entities * disable react/display-name react-hooks/immutability and react-hooks/preserve-manual-memoization * chore: remove unused imports (#4925) remove unused imports * fix: resolve react-hooks ESLint errors (#4929) fix react-hooks linting errors * fix: add rel=noreferrer to target=_blank links (#4928) Fix no target blank errors * fix: resolve undefined variable errors in frontend (#4927) * delete unused file src/components/DataConnectorOption/index.jsx * fix undefined errors * chore: Remove unused variables in frontend (#4924) Remove unused variables --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * lint applied by fixer * simplify tooltips for prompt input items Remove container for images * SambaNova Integration (#4943) * SambaNova Integration * lint * Update LMStudio LLM & Embedder for API token (#4948) - Updates Option panels to be consistent for other providers adds API key to all LMStudio API calls * Web push notifications (#4942) * WIP push notifications * testing push * cleanup for web-push bootstrapping * Fix agent workspace settings loading forever (#4956) remove .brief from SystemSettings.agent_sql_connections * patch warning * patch translator * VN patch for lang/ISO name * fix legacy toggle on confluence page * add provider field to chats (#4959) * make translator placeholder aware * fix bad arabic placeholder that got translated * add provider to map * UAE region support for bedrock models (#4964) * added me-central-1 to bedrock regions * fixed long region name * fix: scroll active sidebar items into view (#4965) * Add centering of settings sidebar link when isActive * abstract redundant logic into a reusable hook * add jsdocs | refactor hook to consume behavior and block args * remove unused import * dev --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * remove deprecated value for Google embedding * linting + tolerate folder deletion for bad ParsedFile inserts * refactor: Migrate system preferences to field-based endpoint and remove deprecated endpoint (#4958) * Migrate all existing deprecated system preferences endpoint services to new service by field | delete old endpoint and service * format * destructure settings from response * nitpick --------- Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * Refactor: Remove redundant message state sync in ChatContainer (#4941) * remove redundant message state sync in ChatContainer * small lint --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * chore: bump ollama SDK from 0.5.10 to 0.6.3 (#4977) upgrade ollama in server to latest (0.6.3) * set embedder output dimensions for LocalAI and Gemini (gemini-embedding-001) (#4980) * Fix Sidebar Clipping When Closed (#4970) fix sidebar clipping when closed * add QA image build for GCHR images * fix GH action color escape * update cleanup to assume repo name * fix build tag lowercase org name * normalize logo wordmark * fix logo jump resolves #4993 * patch out max_tokens from block output amount resolves #3421 * fix: correct TPS calculation for Generic OpenAI provider with llama.cpp (#4981) * add check for timings field on final chunk to override usage data * refactor: extract llama.cpp timings into reusable private method Move timings extraction into #extractTimings so it can be shared by both streaming (handleStream) and non-streaming (getChatCompletion) code paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * lint and cleanup --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Timothy Carambat <rambat1010@gmail.com> * add support for custom headers for LLM Generic OpenAI (#4999) * add support for custom headers for LLM Generic OpenAI * add env * patch out no finish reason from microsoft/Foundry-Local#423 * Update Sponsors README * 1.11.0 release tag * render/railway 1.11.0 --------- Co-authored-by: j0rDy <jkersten84@hotmail.com> Co-authored-by: Marcello Fitton <106866560+angelplusultra@users.noreply.github.com> Co-authored-by: shatfield4 <seanhatfield5@gmail.com> Co-authored-by: Colin Perry <55003831+17ColinMiPerry@users.noreply.github.com> Co-authored-by: Neha Prasad <neh6a683@gmail.com> Co-authored-by: Marcello Fitton <macfittondev@gmail.com> Co-authored-by: vigorous-ride <68917684+vigorous-ride@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: timothycarambat <16845892+timothycarambat@users.noreply.github.com>


Pull Request Type
Relevant Issues
resolves #4809
What is in this change?
This PR refactors username validation to use Unix-style constraints consistently across the entire application with proper internationalization support:
Standardized Username Requirements:
Key Changes:
Centralized Validation Utility - Created
frontend/src/utils/username.jswith:USERNAME_MIN_LENGTH,USERNAME_MAX_LENGTH,USERNAME_PATTERN)/^[a-z][a-z0-9._-]*$/)validateUsername()function for programmatic validation with detailed error messagesInternationalization (i18n) - Added localized username requirement strings:
invite.username_requirementsadmin.users.username_requirementssecurity.multiuser.enable.username_requirementsonboardingandaccountsectionsFrontend Form Updates - All user creation/edit forms now use:
minLength,maxLength,pattern)useTranslation()hookBackend Validation - Updated
server/models/user.js:usernamevalidation function to check regex patternFiles Modified:
frontend/src/utils/username.js(new file)frontend/src/locales/en/common.jsfrontend/src/components/UserMenu/AccountModal/index.jsxfrontend/src/pages/Admin/Users/NewUserModal/index.jsxfrontend/src/pages/Admin/Users/UserRow/EditUserModal/index.jsxfrontend/src/pages/GeneralSettings/Security/index.jsxfrontend/src/pages/Invite/NewUserModal/index.jsxfrontend/src/pages/OnboardingFlow/Steps/UserSetup/index.jsxserver/models/user.jsAdditional Information
The translation normalization updates are included in #4832
Developer Validations
yarn lintfrom the root of the repo & committed changes