refactor(installation): improve allow installation guard
This commit is contained in:
16
packages/backend/src/helpers/allow-installation.js
Normal file
16
packages/backend/src/helpers/allow-installation.js
Normal 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();
|
||||
};
|
Reference in New Issue
Block a user