mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +00:00
use ValidationError
This commit is contained in:
parent
895e0c1fe4
commit
4229f41b4a
@ -2,6 +2,7 @@
|
||||
|
||||
const crypto = require('crypto');
|
||||
const { map, omit, differenceBy } = require('lodash/fp');
|
||||
const { ValidationError } = require('@strapi/utils').errors;
|
||||
const constants = require('../services/constants');
|
||||
|
||||
/**
|
||||
@ -36,12 +37,12 @@ const POPULATE_FIELDS = ['permissions'];
|
||||
const assertCustomTokenPermissionsValidity = attributes => {
|
||||
// Ensure non-custom tokens doesn't have permissions
|
||||
if (attributes.type !== constants.API_TOKEN_TYPE.CUSTOM && attributes.permissions) {
|
||||
throw new Error('Non-custom tokens should not references permissions');
|
||||
throw new ValidationError('Non-custom tokens should not references permissions');
|
||||
}
|
||||
|
||||
// Custom type tokens should always have permissions attached to them
|
||||
if (attributes.type === constants.API_TOKEN_TYPE.CUSTOM && !attributes.permissions) {
|
||||
throw new Error('Missing permissions attributes for custom token');
|
||||
throw new ValidationError('Missing permissions attributes for custom token');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user