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

Bugfix: /api initial flag regression #201

Merged
merged 2 commits into from
Mar 25, 2024
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
14 changes: 12 additions & 2 deletions service/src/app.impl/systemInfo/app.impl.systemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AppResponse } from '../../app.api/app.api.global';
import * as api from '../../app.api/systemInfo/app.api.systemInfo';
import { EnvironmentService } from '../../entities/systemInfo/entities.systemInfo';
import * as Settings from '../../models/setting';
import * as Users from '../../models/user';
import * as AuthenticationConfiguration from '../../models/authenticationconfiguration';
import AuthenticationConfigurationTransformer from '../../transformers/authenticationconfiguration';
import { ExoPrivilegedSystemInfo, ExoRedactedSystemInfo, ExoSystemInfo, SystemInfoPermissionService } from '../../app.api/systemInfo/app.api.systemInfo';
Expand Down Expand Up @@ -54,9 +55,18 @@ export function CreateReadSystemInfo(
): Promise<api.ReadSystemInfoResponse> {
const isAuthenticated = req.context.requestingPrincipal() != null;

// FIXME: Replace this with Robert's first-run secret implementation when available
const legacyUsers = Users as any;
const userCount = await new Promise(resolve => {
legacyUsers.count({}, (err:any, count:any) => {
resolve(count)
});
});

// Initialize with base system info
let systemInfoResponse: ExoRedactedSystemInfo = {
version: versionInfo,
let systemInfoResponse: ExoRedactedSystemInfo = {
version: versionInfo,
initial: userCount == 0,
disclaimer: (await settingsModule.getSetting('disclaimer')) || {},
contactInfo: (await settingsModule.getSetting('contactInfo')) || {}
};
Expand Down
1 change: 1 addition & 0 deletions service/src/entities/systemInfo/entities.systemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface SystemInfo {
* Package version string straight from package.json
*/
environment: EnvironmentInfo
initial: boolean // is in initial setup with no users
disclaimer: any // mongoose Document type
contactInfo: any
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('SystemInfo web controller', () => {
nodeVersion: 'test',
mongodbVersion: 'test'
},
initial: true,
disclaimer: {},
contactInfo: {},
version: {
Expand Down
Loading