fix(core): Do not return inviteAcceptUrl in response if email was sent (#7465)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-10-19 13:58:06 +02:00
committed by GitHub
parent ab6a9bbac2
commit 55c6a1b0d3
11 changed files with 74 additions and 102 deletions

View File

@@ -10,7 +10,6 @@ import {
generateUserInviteUrl,
getInstanceBaseUrl,
hashPassword,
isEmailSetUp,
validatePassword,
} from '@/UserManagement/UserManagementHelper';
import { issueCookie } from '@/auth/jwt';
@@ -184,7 +183,7 @@ export class UsersController {
}
const inviteAcceptUrl = generateUserInviteUrl(req.user.id, id);
const resp: {
user: { id: string | null; email: string; inviteAcceptUrl: string; emailSent: boolean };
user: { id: string | null; email: string; inviteAcceptUrl?: string; emailSent: boolean };
error?: string;
} = {
user: {
@@ -202,6 +201,7 @@ export class UsersController {
});
if (result.emailSent) {
resp.user.emailSent = true;
delete resp.user.inviteAcceptUrl;
void this.internalHooks.onUserTransactionalEmail({
user_id: id,
message_type: 'New user invite',
@@ -619,7 +619,7 @@ export class UsersController {
throw new UnauthorizedError(RESPONSE_ERROR_MESSAGES.USERS_QUOTA_REACHED);
}
if (!isEmailSetUp()) {
if (!this.mailer.isEmailSetUp) {
this.logger.error('Request to reinvite a user failed because email sending was not set up');
throw new InternalServerError('Email sending must be set up in order to invite other users');
}