feat: Allow email addresses as usernames (#4619)

Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
Neha Prasad 2025-11-20 03:13:28 +05:30 committed by GitHub
parent b86aca765b
commit ea336de3c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,7 @@ const { EventLogs } = require("./eventLogs");
*/
const User = {
usernameRegex: new RegExp(/^[a-z0-9_\-.]+$/),
usernameRegex: new RegExp(/^[a-zA-Z0-9._%+-@]+$/),
writable: [
// Used for generic updates so we can validate keys in request body
"username",
@ -95,7 +95,7 @@ const User = {
// Do not allow new users to bypass validation
if (!this.usernameRegex.test(username))
throw new Error(
"Username must only contain lowercase letters, periods, numbers, underscores, and hyphens with no spaces"
"Username must only contain letters, numbers, periods, underscores, hyphens, and email characters (@, %, +, -) with no spaces"
);
const bcrypt = require("bcrypt");
@ -175,7 +175,7 @@ const User = {
return {
success: false,
error:
"Username must only contain lowercase letters, periods, numbers, underscores, and hyphens with no spaces",
"Username must only contain letters, numbers, periods, underscores, hyphens, and email characters (@, %, +, -) with no spaces",
};
const user = await prisma.users.update({