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
5 changes: 5 additions & 0 deletions .changeset/poor-forks-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an error regarding `DEBUG_DISABLE_USER_AUDIT` flag being deprecated which was preventing the server from starting up.
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/ApiClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
// We have some breaking changes planned to the API.
// To avoid conflicts or missing something during the period we are adopting a 'feature flag approach'
// TODO: MAJOR check if this is still needed
const applyBreakingChanges = shouldBreakInVersion('8.0.0');
const applyBreakingChanges = shouldBreakInVersion('9.0.0');
type MinimalRoute = {
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
path: string;
Expand Down Expand Up @@ -829,10 +829,10 @@

if (options.authRequired || options.authOrAnonRequired) {
const user = await api.authenticatedRoute(this);
this.user = user!;

Check warning on line 832 in apps/meteor/app/api/server/ApiClass.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
this.userId = this.user?._id;
const authToken = this.request.headers.get('x-auth-token');
this.token = (authToken && Accounts._hashLoginToken(String(authToken)))!;

Check warning on line 835 in apps/meteor/app/api/server/ApiClass.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
}

const shouldPreventAnonymousRead = !this.user && options.authOrAnonRequired && !settings.get('Accounts_AllowAnonymousRead');
Expand Down Expand Up @@ -912,7 +912,7 @@
connection,
};

Accounts._setAccountData(connection.id, 'loginToken', this.token!);

Check warning on line 915 in apps/meteor/app/api/server/ApiClass.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion

this.userId &&
(await api.processTwoFactor({
Expand Down
9 changes: 4 additions & 5 deletions apps/meteor/app/lib/server/functions/saveUser/saveUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,15 @@ const _saveUser = (session?: ClientSession) =>
return true;
};

const isBroken = shouldBreakInVersion('8.0.0');
const isBroken = shouldBreakInVersion('9.0.0');
export const saveUser = (() => {
if (isBroken) {
throw new Error('DEBUG_DISABLE_USER_AUDIT flag is deprecated and should be removed');
}

if (!process.env.DEBUG_DISABLE_USER_AUDIT) {
return wrapInSessionTransaction(_saveUser);
}

if (isBroken) {
throw new Error('DEBUG_DISABLE_USER_AUDIT flag is deprecated and should be removed');
}
const saveUserNoSession = _saveUser();
return function saveUser(userId: IUser['_id'], userData: SaveUserData, _options?: any) {
return saveUserNoSession(userId, userData);
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/server/lib/shouldBreakInVersion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import semver from 'semver';

import type { DeprecationLoggerNextPlannedVersion } from '../../app/lib/server/lib/deprecationWarningLogger';
import { Info } from '../../app/utils/rocketchat.info';

export const shouldBreakInVersion = (version: string) => semver.gte(Info.version, version);
export const shouldBreakInVersion = (version: DeprecationLoggerNextPlannedVersion) => semver.gte(Info.version, version);
Loading