refactor(installation): improve allow installation guard

This commit is contained in:
Ali BARIN
2024-05-13 14:00:12 +00:00
parent b30f97db3e
commit c80791267f
5 changed files with 44 additions and 12 deletions

View File

@@ -0,0 +1,16 @@
import Config from '../models/config.js';
import User from '../models/user.js';
export async function allowInstallation(request, response, next) {
if (await Config.isInstallationCompleted()) {
return response.status(403).end();
}
const hasAnyUsers = await User.query().resultSize() > 0;
if (hasAnyUsers) {
return response.status(403).end();
}
next();
};

View File

@@ -1,9 +0,0 @@
import Config from '../models/config.js';
export async function authorizeInstallation(request, response, next) {
if (await Config.isInstallationCompleted()) {
return response.status(403).end();
} else {
next();
}
};