diff --git a/db/seeds/010-collections-types.js b/db/seeds/010-collections-types.js index 190a031..3957ceb 100644 --- a/db/seeds/010-collections-types.js +++ b/db/seeds/010-collections-types.js @@ -9,24 +9,34 @@ exports.seed = async function (knex) { await knex(COLLECTIONS_TYPES_TABLE).del(); await knex(COLLECTIONS_TYPES_TABLE).insert([ { - slug: 'red', - label: 'Red', - flavor: 'red', + // id = 1 + slug: 'requests', + label: 'Requests', + flavor: '#900', }, { - slug: 'blue', - label: 'Blue', - flavor: 'blue', + // id = 2 + slug: 'samples', + label: 'Samples', + flavor: '#ccc', }, { - slug: 'green', - label: 'Green', - flavor: 'green', + // id = 3 + slug: 'statuses', + label: 'Statuses', + flavor: '#fff', }, { - slug: 'orange', - label: 'Orange', - flavor: 'orange', + // id = 4 + slug: 'phases', + label: 'Materials', + flavor: '#666', + }, + { + // id = 5 + slug: 'customers', + label: 'Customers', + flavor: '#5755D9', }, ]); }; diff --git a/db/seeds/030-users.js b/db/seeds/030-users.js index 3bd6ead..b20aa1a 100644 --- a/db/seeds/030-users.js +++ b/db/seeds/030-users.js @@ -34,12 +34,6 @@ exports.seed = async function (knex) { roleId: adminRole.id, password, }, - { - firstName: 'Test', - lastName: 'Test', - roleId: memberRole.id, - password, - }, ], ['id'] ); @@ -49,11 +43,9 @@ exports.seed = async function (knex) { const memberEmail = 'member@test.com'; const adminEmail = 'admin@test.com'; - const testEmail = 'test@test.com'; const code1 = await hashString(memberEmail); const code2 = await hashString(adminEmail); - const code3 = await hashString(testEmail); await knex(USERS_EMAILS_TABLE).insert([ { @@ -66,10 +58,5 @@ exports.seed = async function (knex) { email: adminEmail, code: code2, }, - { - userId: test.id, - email: testEmail, - code: code3, - }, ]); }; diff --git a/routes/[version]/apikey.js b/routes/[version]/apikey.js index 4fdc198..b2823d9 100644 --- a/routes/[version]/apikey.js +++ b/routes/[version]/apikey.js @@ -2,14 +2,15 @@ const crypto = require('crypto'); const { checkAuth } = require('../../middlewares/auth'); const { selectAPIToken, setAPIToken, removeAPIToken } = require('../../services/db'); +const generateAPIToken = (length = 11) => 'METIS_' + crypto.randomBytes(length).toString('hex'); // 28 chars + module.exports = { get: [checkAuth, get], put: [checkAuth, put], delete: [checkAuth, del], + generateAPIToken, }; -const generateAPIToken = (length = 11) => 'METIS_' + crypto.randomBytes(length).toString('hex'); // 28 chars - /** * @api {put} /v0/apikey Create new API key * @apiName SetAPIKey diff --git a/services/db.js b/services/db.js index 58c86be..c45a07f 100644 --- a/services/db.js +++ b/services/db.js @@ -81,29 +81,15 @@ const ADMIN_USER_ROLE = 'admin'; const PUBLIC_COLLECTION_VISIBILITY = 'community'; const SHARED_COLLECTION_VISIBILITY = 'shared'; const PRIVATE_COLLECTION_VISIBILITY = 'private'; - -const OAUTH_PROVIDERS_ENUM = ['dummy', 'github', 'linkedin', 'orcid', 'mpds', 'basf']; -const FLAVORS_ENUM = [ - 'red', - 'pink', - 'purple', - 'indigo', - 'blue', - 'cyan', - 'teal', - 'green', - 'lime', - 'yellow', - 'orange', - 'brown', - 'grey', -]; const VISIBILITY_ENUM = [ PRIVATE_COLLECTION_VISIBILITY, SHARED_COLLECTION_VISIBILITY, PUBLIC_COLLECTION_VISIBILITY, ]; +const OAUTH_PROVIDERS_ENUM = ['dummy', 'github', 'linkedin', 'orcid', 'mpds', 'basf']; +const FLAVORS_ENUM = ['#900', '#ccc', '#fff', '#666', '#5755D9']; + const selectDataSourcesByUserId = selectAllByUserId(USER_DATASOURCES_TABLE, DATASOURCE_FIELDS); const selectCalculationsByUserId = selectAllByUserId(USER_CALCULATIONS_TABLE); const deleteUserDataSource = deleteFirstByUserId(USER_DATASOURCES_TABLE);