Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Added MaxNickNameLength and MaxBioLength constants #25231

Merged
merged 2 commits into from
Apr 19, 2022
Merged
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
7 changes: 5 additions & 2 deletions apps/meteor/app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { checkEmailAvailability, checkUsernameAvailability, setUserAvatar, setEm
import { Users } from '../../../models/server';
import { callbacks } from '../../../../lib/callbacks';

const MAX_BIO_LENGTH = 260;
const MAX_NICKNAME_LENGTH = 120;

let html = '';
let passwordChangedHtml = '';
Meteor.startup(() => {
Expand Down Expand Up @@ -228,7 +231,7 @@ export function validateUserEditing(userId, userData) {

const handleBio = (updateUser, bio) => {
if (bio && bio.trim()) {
if (typeof bio !== 'string' || bio.length > 260) {
if (typeof bio !== 'string' || bio.length > MAX_BIO_LENGTH) {
throw new Meteor.Error('error-invalid-field', 'bio', {
method: 'saveUserProfile',
});
Expand All @@ -243,7 +246,7 @@ const handleBio = (updateUser, bio) => {

const handleNickname = (updateUser, nickname) => {
if (nickname && nickname.trim()) {
if (typeof nickname !== 'string' || nickname.length > 120) {
if (typeof nickname !== 'string' || nickname.length > MAX_NICKNAME_LENGTH) {
throw new Meteor.Error('error-invalid-field', 'nickname', {
method: 'saveUserProfile',
});
Expand Down