Skip to content

Commit

Permalink
bugfix: replace missing initial parameter on /api endpoint to support…
Browse files Browse the repository at this point in the history
… initial user setup

This temporarily fixes a regression on the develop branch from the TS migration that blocked first-run initial admin setup.
Robert is planning to replace how this will work with a secret-based approach rather than racing to create an admin user on the first run when zero users exist.
  • Loading branch information
jimcheng256 committed Mar 25, 2024
1 parent 3a7b2e5 commit a79c40f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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
}

0 comments on commit a79c40f

Please sign in to comment.