Skip to content

Commit

Permalink
[keyserver][lib] Block users from creating reserved invite links
Browse files Browse the repository at this point in the history
Summary:
A user should not be able to create a link which is included in a list of reserved usernames. The copy is similar to a message that is shown when a user tries to create an account with reserved username: `/native/account/registration/registration-server-call.js`, but I'm not sure if we should mention support email (the user is already registered and can contact us on Comm).

Depends on D8527

Test Plan: Try to create `/comm` invite link - a message should be displayed.

Reviewers: kamil, inka, ashoat

Reviewed By: inka

Differential Revision: https://phab.comm.dev/D8615
  • Loading branch information
palys-swm committed Jul 28, 2023
1 parent 9370f91 commit 4ba08e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions keyserver/src/creators/invite-link-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
} from 'lib/types/link-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import { ServerError } from 'lib/utils/errors.js';
import { reservedUsernamesSet } from 'lib/utils/reserved-users.js';

import createIDs from './id-creator.js';
import {
Expand All @@ -33,6 +34,9 @@ async function createOrUpdatePublicLink(
if (badWordsFilter.isProfane(request.name)) {
throw new ServerError('offensive_words');
}
if (reservedUsernamesSet.has(request.name)) {
throw new ServerError('link_reserved');
}

const permissionPromise = checkThreadPermission(
viewer,
Expand Down
5 changes: 4 additions & 1 deletion lib/shared/invite-links.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// @flow

const inviteLinkErrorMessages = {
const inviteLinkErrorMessages: { +[string]: string } = {
invalid_characters: 'Link cannot contain any spaces or special characters.',
offensive_words: 'No offensive or abusive words allowed.',
already_in_use: 'Public link URL already in use.',
link_reserved:
'This public link is currently reserved. Please contact support@' +
'comm.app if you would like to claim this link.',
};

const defaultErrorMessage = 'Unknown error.';
Expand Down

0 comments on commit 4ba08e6

Please sign in to comment.