θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions frontend/src/pages/Admin/Users/NewUserModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,10 @@ export default function NewUserModal({ closeModal }) {
minLength={2}
required={true}
autoComplete="off"
pattern="^[a-z0-9_-]+$"
onInvalid={(e) =>
e.target.setCustomValidity(
"Username must only contain lowercase letters, numbers, underscores, and hyphens with no spaces"
)
}
onChange={(e) => e.target.setCustomValidity("")}
/>
<p className="mt-2 text-xs text-white/60">
Username must only contain lowercase letters, numbers,
underscores, and hyphens with no spaces
Username must only contain lowercase letters, periods,
numbers, underscores, and hyphens with no spaces
</p>
</div>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export default function EditUserModal({ currentUser, user, closeModal }) {
autoComplete="off"
/>
<p className="mt-2 text-xs text-white/60">
Username must only contain lowercase letters, numbers,
underscores, and hyphens with no spaces
Username must only contain lowercase letters, periods,
numbers, underscores, and hyphens with no spaces
</p>
</div>
<div>
Expand Down
6 changes: 3 additions & 3 deletions server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { EventLogs } = require("./eventLogs");
*/

const User = {
usernameRegex: new RegExp(/^[a-z0-9_-]+$/),
usernameRegex: new RegExp(/^[a-z0-9_\-.]+$/),
writable: [
// Used for generic updates so we can validate keys in request body
"username",
Expand Down Expand Up @@ -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, numbers, underscores, and hyphens with no spaces"
"Username must only contain lowercase letters, periods, numbers, underscores, and hyphens with no spaces"
);

const bcrypt = require("bcrypt");
Expand Down Expand Up @@ -175,7 +175,7 @@ const User = {
return {
success: false,
error:
"Username must only contain lowercase letters, numbers, underscores, and hyphens with no spaces",
"Username must only contain lowercase letters, periods, numbers, underscores, and hyphens with no spaces",
};

const user = await prisma.users.update({
Expand Down