chore: Rename for consistency
This commit is contained in:
@@ -119,7 +119,7 @@
|
||||
* enum:
|
||||
* - Email already in use
|
||||
* - Username already in use
|
||||
* - Active users limit reached
|
||||
* - Active user limit reached
|
||||
* description: Specific error message
|
||||
* example: Email already in use
|
||||
* 422:
|
||||
@@ -182,8 +182,8 @@ const Errors = {
|
||||
USERNAME_ALREADY_IN_USE: {
|
||||
usernameAlreadyInUse: 'Username already in use',
|
||||
},
|
||||
ACTIVE_USERS_LIMIT_REACHED: {
|
||||
activeUsersLimitReached: 'Active users limit reached',
|
||||
ACTIVE_USER_LIMIT_REACHED: {
|
||||
activeUserLimitReached: 'Active user limit reached',
|
||||
},
|
||||
MISSING_VALUES: {
|
||||
missingValues: 'Unable to retrieve required values (email, name)',
|
||||
@@ -229,7 +229,7 @@ module.exports = {
|
||||
usernameAlreadyInUse: {
|
||||
responseType: 'conflict',
|
||||
},
|
||||
activeUsersLimitReached: {
|
||||
activeUserLimitReached: {
|
||||
responseType: 'conflict',
|
||||
},
|
||||
missingValues: {
|
||||
@@ -250,7 +250,7 @@ module.exports = {
|
||||
.intercept('invalidUserinfoConfiguration', () => Errors.INVALID_USERINFO_CONFIGURATION)
|
||||
.intercept('emailAlreadyInUse', () => Errors.EMAIL_ALREADY_IN_USE)
|
||||
.intercept('usernameAlreadyInUse', () => Errors.USERNAME_ALREADY_IN_USE)
|
||||
.intercept('activeLimitReached', () => Errors.ACTIVE_USERS_LIMIT_REACHED)
|
||||
.intercept('activeLimitReached', () => Errors.ACTIVE_USER_LIMIT_REACHED)
|
||||
.intercept('missingValues', () => Errors.MISSING_VALUES);
|
||||
|
||||
return sails.helpers.accessTokens.handleSteps
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
* type: boolean
|
||||
* description: Whether OIDC authentication is enforced (users must use OIDC to login)
|
||||
* example: false
|
||||
* activeUsersLimit:
|
||||
* activeUserLimit:
|
||||
* type: number
|
||||
* nullable: true
|
||||
* description: Maximum number of active users allowed (conditionally added for admins if configured)
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = {
|
||||
};
|
||||
if (inputs.user && inputs.user.role === User.Roles.ADMIN) {
|
||||
Object.assign(data, {
|
||||
activeUsersLimit: sails.config.custom.activeUsersLimit,
|
||||
activeUserLimit: sails.config.custom.activeUserLimit,
|
||||
customerPanelUrl: sails.config.custom.customerPanelUrl,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const defaultFind = (criteria) => User.find(criteria).sort('id');
|
||||
/* Query methods */
|
||||
|
||||
const createOne = (values) => {
|
||||
if (sails.config.custom.activeUsersLimit !== null) {
|
||||
if (sails.config.custom.activeUserLimit !== null) {
|
||||
return sails.getDatastore().transaction(async (db) => {
|
||||
const queryResult = await sails
|
||||
.sendNativeQuery('SELECT NULL FROM user_account WHERE is_deactivated = $1 FOR UPDATE', [
|
||||
@@ -33,7 +33,7 @@ const createOne = (values) => {
|
||||
])
|
||||
.usingConnection(db);
|
||||
|
||||
if (queryResult.rowCount >= sails.config.custom.activeUsersLimit) {
|
||||
if (queryResult.rowCount >= sails.config.custom.activeUserLimit) {
|
||||
throw 'activeLimitReached';
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ const getOneActiveByApiKeyHash = (apiKeyHash) =>
|
||||
|
||||
const updateOne = async (criteria, values) => {
|
||||
const enforceActiveLimit =
|
||||
values.isDeactivated === false && sails.config.custom.activeUsersLimit !== null;
|
||||
values.isDeactivated === false && sails.config.custom.activeUserLimit !== null;
|
||||
|
||||
if (!_.isUndefined(values.avatar) || enforceActiveLimit) {
|
||||
return sails.getDatastore().transaction(async (db) => {
|
||||
@@ -98,7 +98,7 @@ const updateOne = async (criteria, values) => {
|
||||
])
|
||||
.usingConnection(db);
|
||||
|
||||
if (queryResult.rowCount >= sails.config.custom.activeUsersLimit) {
|
||||
if (queryResult.rowCount >= sails.config.custom.activeUserLimit) {
|
||||
throw 'activeLimitReached';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user