diff --git a/src/adonisjs/app/Controllers/Http/PermissionController.js b/src/adonisjs/app/Controllers/Http/PermissionController.js new file mode 100644 index 0000000..8d93f1c --- /dev/null +++ b/src/adonisjs/app/Controllers/Http/PermissionController.js @@ -0,0 +1,37 @@ +'use strict' + +const uuidv4 = require('uuid/v4') + + +const Permission = use('App/Models/v1/Permission') +const Environment = use('App/Models/Environment') + + +class PermissionController { + async store ({ request, response }) { + try { + let permission = new Permission() + permission.id = await uuidv4() + + permission.clearance = request.input('clearance') + permission.subject_grade = request.input('subject_grade') + permission.resource = request.input('resource') + permission.resource_id = request.input('resource_id') + + + let environment = await Environment.findBy('name', request.input('environment')) + permission.environment_id = environment.id + + + + await permission.save() + + response.json('permission successfully created') + } catch (e) { + console.log(e) + return response.status(500).json({ message: e.message }) + } + } +} + +module.exports = PermissionController diff --git a/src/adonisjs/app/Controllers/Http/v1/CaseController.js b/src/adonisjs/app/Controllers/Http/v1/CaseController.js index 8769ba8..97cf7b6 100644 --- a/src/adonisjs/app/Controllers/Http/v1/CaseController.js +++ b/src/adonisjs/app/Controllers/Http/v1/CaseController.js @@ -129,12 +129,10 @@ class CaseController { } /** * Update case details. PUT or PATCH case/:id */ - async update ({ request, response }) { + async update ({ params, request, response }) { const trx = await Database.beginTransaction() - try { - const c = await Case.find(request.input('caseId')) - + const c = await Case.find(params.id) if (c != null) { c.title = request.input('title') || null c.description = request.input('description')|| null @@ -150,33 +148,38 @@ class CaseController { cv.source = request.input('source') cv.id = await uuidv4() await c.versions().save(cv) - const institutionAcronym = request.input('institution') if (institutionAcronym != null){ let institution = await Institution.findBy('acronym', institutionAcronym) await c.institution().associate(institution) } - const permission = new Permission() - permission.id = await uuidv4() - permission.entity = request.input('permissionEntity') - permission.subject = request.input('permissionSubjectId') - permission.clearance = request.input('permissionClearance') - permission.table = 'cases' - permission.table_id = c.id - permission.save(trx) + // const permission = new Permission() + // permission.id = await uuidv4() + // permission.entity = request.input('permissionEntity') + // permission.subject = request.inpuission = new Permission() + // permission.id = await uuidv4() + // permission.entity = request.input('permissionEntity') + // permission.subject = request.input('permissionSubjectId') + // permission.clearance = request.input('permissionClearance') + // permission.table = 'cases' + // permission.table_id = c.id + // permission.t('permissionSubjectId') + // permission.clearance = request.input('permissionClearance') + // permission.table = 'cases' + // permission.table_id = c.id + // permission.save(trx) await c.save() trx.commit() - return response.json(c) } else return response.status(500).json('case not found') } catch (e) { trx.rollback() console.log(e) - return response.status(500).json({ message: e }) + return response.status(500).json({ message: e.message }) } } diff --git a/src/adonisjs/app/Controllers/Http/v1/UserController.js b/src/adonisjs/app/Controllers/Http/v1/UserController.js index abd372b..7db9759 100644 --- a/src/adonisjs/app/Controllers/Http/v1/UserController.js +++ b/src/adonisjs/app/Controllers/Http/v1/UserController.js @@ -219,7 +219,7 @@ class UserController { THEN 'Feedback complete' ELSE case_properties.value END AS ?`,[propertyFilter])]) .distinct('cases.id') .from('cases') - .leftJoin('permissions', 'cases.id', 'permissions.table_id') + // .leftJoin('permissions', 'cases.id', 'permissions.table_id') .join('case_properties', 'case_properties.case_id', 'cases.id') .join('properties', 'properties.id', 'case_properties.property_id') .join('users', 'users.id', 'cases.author_id') @@ -234,21 +234,21 @@ class UserController { this.where('cases.specialty', 'like', specialtyFilter) }) - .where(function(){ - this - .where('cases.author_id', user.id) - .orWhere(function () { - this - .where('permissions.entity', 'institution') - .where('permissions.subject', user.institution_id) - .where('permissions.clearance', '>=', clearance) - .where(function(){ - this - .whereNull('permissions.subject_grade') - .orWhere('permissions.subject_grade', user.grade) - }) - }) - }) + // .where(function(){ + // this + // .where('cases.author_id', user.id) + // .orWhere(function () { + // this + // .where('permissions.resource', 'cases') + // .where('permissions.resource_id', user.institution_id) + // .where('permissions.clearance', '>=', clearance) + // .where(function(){ + // this + // .whereNull('permissions.subject_grade') + // .orWhere('permissions.subject_grade', user.grade) + // }) + // }) + // }) .orderBy('cases.created_at', 'desc') }else{ @@ -260,7 +260,7 @@ class UserController { 'institutions.country AS institution_country', 'cases.created_at']) .distinct('cases.id') .from('cases') - .leftJoin('permissions', 'cases.id', 'permissions.table_id') + // .leftJoin('permissions', 'cases.id', 'permissions.table_id') .join('users', 'users.id', 'cases.author_id') .join('institutions', 'users.institution_id', 'institutions.id') .where('cases.published', '>=', publishedFilter) @@ -271,21 +271,21 @@ class UserController { this.where('cases.specialty', 'like', specialtyFilter) }) - .where(function(){ - this - .where('cases.author_id', user.id) - .orWhere(function () { - this - .where('permissions.entity', 'institution') - .where('permissions.subject', user.institution_id) - .where('permissions.clearance', '>=', clearance) - .where(function(){ - this - .whereNull('permissions.subject_grade') - .orWhere('permissions.subject_grade', user.grade) - }) - }) - }) + // .where(function(){ + // this + // .where('cases.author_id', user.id) + // .orWhere(function () { + // this + // .where('permissions.entity', 'institution') + // .where('permissions.subject', user.institution_id) + // .where('permissions.clearance', '>=', clearance) + // .where(function(){ + // this + // .whereNull('permissions.subject_grade') + // .orWhere('permissions.subject_grade', user.grade) + // }) + // }) + // }) .orderBy('cases.created_at', 'desc') } diff --git a/src/adonisjs/app/Middleware/CheckCasePermission.js b/src/adonisjs/app/Middleware/CheckCasePermission.js index 5b670a8..f9222a7 100644 --- a/src/adonisjs/app/Middleware/CheckCasePermission.js +++ b/src/adonisjs/app/Middleware/CheckCasePermission.js @@ -13,6 +13,7 @@ class CheckPermissionForGivenCase { */ async handle ({ params, request, response, auth }, next, properties) { try { + console.log('kokokok') const loggedUserId = auth.user.id let sqlQuery = '' let caseId = '' diff --git a/src/adonisjs/app/Middleware/CheckPermission.js b/src/adonisjs/app/Middleware/CheckPermission.js new file mode 100644 index 0000000..be05c2f --- /dev/null +++ b/src/adonisjs/app/Middleware/CheckPermission.js @@ -0,0 +1,64 @@ +'use strict' +/** @typedef {import('@adonisjs/framework/src/Request')} Request */ +/** @typedef {import('@adonisjs/framework/src/Response')} Response */ +/** @typedef {import('@adonisjs/framework/src/View')} View */ + +const Database = use('Database') + +class CheckPermission { + /** + * @param {object} ctx + * @param {Request} ctx.request + * @param {Function} next + */ + async handle ({ params, request, response, auth }, next, properties) { + try { + let resourceId = params.id + if (resourceId == undefined){ + resourceId = request.input('caseId') + } + const user = await auth.user + const resource = properties[0] + const clearance = properties[1] + // console.log(user.environment_id) + const environment = await user.environment + // const environment = await user.environment().fetch() + + // c.versions = await c.versions().fetch() + console.log('clearance: '+clearance ) + console.log('resource: '+resource) + console.log('resourceId: '+resourceId) + console.log('environment: '+user.environment_id) + + let queryResult + const clearances = ['read', 'comment', 'share', 'write', 'delete'] + const clearanceIindex = clearances.indexOf(clearance) + // console.log('clearance '+ clearanceIindex) + + queryResult = await Database + .from('permissions') + .leftJoin('environments', 'environments.id', 'permissions.environment_id') + // .where('environments.id', environment.id) + + .leftJoin('users', 'users.environment_id', 'environments.id') + .where('users.environment_id', user.environment_id) + .where('permissions.clearance', '>=', clearanceIindex) + .where('permissions.resource', resource) + .where('permissions.resource_id', resourceId) + .count() + + console.log('queryResult '+queryResult[0]['count(*)']) + if (queryResult[0]['count(*)'] === 0) { + return response.status(500).json('you dont have permission to ' + clearance + ' such ' + resource) + } else { + await next() + } + + } catch (e) { + console.log(e) + return response.status(500).json(e) + } + } +} + +module.exports = CheckPermission diff --git a/src/adonisjs/app/Models/Environment.js b/src/adonisjs/app/Models/Environment.js new file mode 100644 index 0000000..c9146c3 --- /dev/null +++ b/src/adonisjs/app/Models/Environment.js @@ -0,0 +1,12 @@ +'use strict' + +/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ +const Model = use('Model') + +class Environment extends Model { + static get incrementing () { + return false + } +} + +module.exports = Environment diff --git a/src/adonisjs/app/Models/v1/Permission.js b/src/adonisjs/app/Models/v1/Permission.js index 90f70a6..58a9d18 100644 --- a/src/adonisjs/app/Models/v1/Permission.js +++ b/src/adonisjs/app/Models/v1/Permission.js @@ -7,6 +7,10 @@ class Permission extends Model { static get incrementing () { return false } + + environment () { + return this.belongsTo('App/Models/Environment') + } } module.exports = Permission diff --git a/src/adonisjs/app/Models/v1/User.js b/src/adonisjs/app/Models/v1/User.js index e4fad65..3b55c64 100644 --- a/src/adonisjs/app/Models/v1/User.js +++ b/src/adonisjs/app/Models/v1/User.js @@ -4,9 +4,11 @@ const Hash = use('Hash') /** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ const Model = use('Model') - const Database = use('Database') +const Environment = use('App/Models/Environment') + + class User extends Model { static get incrementing () { return false @@ -26,6 +28,61 @@ class User extends Model { .withTimestamps() } + environment () { + return this.belongsTo('App/Models/Environment') + } + // environment () { + // return this.belongsTo('App/Models/Environment') + // } + // environment () { + // return this + // .belongsToMany('App/Models/Group') + // .pivotTable('users_groups') + // .withTimestamps() + // } + +// async environment (){ +// let queryResult = await Database +// .from('environments') +// .leftJoin('users', 'users.environment_id', 'environments.id') +// .where('users.id', this.id) +// // .where('users_environments.environment_id', caseId) +// // .whereIn('users_cases.permission', ['share', 'write', 'delete']) +// // .count() +// queryResult +// const result = JSON.stringify(queryResult) +// // console.log(queryResult[0]['id']) +// // console.log(queryResult[0]['name']) +// +// // for (var r in result) { +// // console.log(r) +// // +// // } +// // result.forEach((item, i) => { +// // console.log(r) +// // }); +// console.log('result '+result) +// if (result.length==0){ +// console.log('aquiiiiiiiiiiiiiii') +// // let environment +// // environment.name = 'public' +// return 'unicamp' +// } +// console.log(queryResult) +// if (queryResult[0]['count(*)'] === 0) { +// return response.status(500).json('you dont have permission to ' + properties[0] + ' such case') +// } else { +// const environment = new Environment() +// // environment. +// const environmet = Environment +// // console.log(result[0]) +// return queryResult[0]['name'] +// // await next() +// } +// return queryResult +// +// } + artifacts () { return this.hasMany('App/Models/v1/Artifact') } diff --git a/src/adonisjs/database/migrations/1616133252647_drop_users_groups_schema.js b/src/adonisjs/database/migrations/1616133252647_drop_users_groups_schema.js new file mode 100644 index 0000000..f3fa7e1 --- /dev/null +++ b/src/adonisjs/database/migrations/1616133252647_drop_users_groups_schema.js @@ -0,0 +1,22 @@ +'use strict' + +/** @type {import('@adonisjs/lucid/src/Schema')} */ +const Schema = use('Schema') + +class DropUsersGroupsSchema extends Schema { + up () { + this.dropIfExists('users_groups') + } + + down () { + this.create('users_groups', (table) => { + table.uuid('user_id').references('id').inTable('users').index('user_id') + table.uuid('group_id').references('id').inTable('groups').index('group_id') + table.primary(['group_id', 'user_id']) + + table.timestamps() + }) + } +} + +module.exports = DropUsersGroupsSchema diff --git a/src/adonisjs/database/migrations/1616133614175_drop_groups_schema.js b/src/adonisjs/database/migrations/1616133614175_drop_groups_schema.js new file mode 100644 index 0000000..4eb059a --- /dev/null +++ b/src/adonisjs/database/migrations/1616133614175_drop_groups_schema.js @@ -0,0 +1,21 @@ +'use strict' + +/** @type {import('@adonisjs/lucid/src/Schema')} */ +const Schema = use('Schema') + +class DropGroupSchema extends Schema { + up () { + this.dropIfExists('groups') + } + + down () { + this.create('groups', (table) => { + table.uuid('id') + table.primary('id') + table.string('title') + table.timestamps() + }) + } +} + +module.exports = DropGroupSchema diff --git a/src/adonisjs/database/migrations/1616133798887_environment_schema.js b/src/adonisjs/database/migrations/1616133798887_environment_schema.js new file mode 100644 index 0000000..a83b6f6 --- /dev/null +++ b/src/adonisjs/database/migrations/1616133798887_environment_schema.js @@ -0,0 +1,24 @@ +'use strict' + +/** @type {import('@adonisjs/lucid/src/Schema')} */ +const Schema = use('Schema') + +class EnvironmentSchema extends Schema { + up () { + this.dropIfExists('environments') + + this.create('environments', (table) => { + table.uuid('id') + table.primary('id') + table.string('name') + table.timestamps() + }) + + } + + down () { + this.drop('environments') + } +} + +module.exports = EnvironmentSchema diff --git a/src/adonisjs/database/migrations/1616135847286_refact_permissions_schema.js b/src/adonisjs/database/migrations/1616135847286_refact_permissions_schema.js new file mode 100644 index 0000000..0f0b091 --- /dev/null +++ b/src/adonisjs/database/migrations/1616135847286_refact_permissions_schema.js @@ -0,0 +1,42 @@ +'use strict' + +/** @type {import('@adonisjs/lucid/src/Schema')} */ +const Schema = use('Schema') + +class UpdatePermissionSchema extends Schema { + up () { + this.table('permissions', (table) => { + // alter table + // table.dropColumn('environment_id') + // table.dropForeign('environment_id') + // table.dropColumn('environment_id') + table.uuid('environment_id').references('id').inTable('environments').index('environment_id') + + table.string('resource') + table.uuid('resource_id') + + table.dropColumn('entity') + table.dropColumn('subject') + table.dropColumn('table') + table.dropColumn('table_id') + + }) + } + + down () { + this.table('permissions', (table) => { + // reverse alternations + table.dropForeign('environment_id') + table.dropColumn('environment_id') + table.dropColumn('resource_id') + table.dropColumn('resource') + + table.string('entity') + table.string('subject') + table.string('table') + table.uuid('table_id') + }) + } +} + +module.exports = UpdatePermissionSchema diff --git a/src/adonisjs/database/migrations/1616137109878_update_users_add_env_attr_schema.js b/src/adonisjs/database/migrations/1616137109878_update_users_add_env_attr_schema.js new file mode 100644 index 0000000..f81382d --- /dev/null +++ b/src/adonisjs/database/migrations/1616137109878_update_users_add_env_attr_schema.js @@ -0,0 +1,21 @@ +'use strict' + +/** @type {import('@adonisjs/lucid/src/Schema')} */ +const Schema = use('Schema') + +class UpdateUsersAddEnvAttrSchema extends Schema { + up () { + this.table('users', (table) => { + table.uuid('environment_id').references('id').inTable('environments').index('environment_id') + }) + } + + down () { + this.table('users', (table) => { + table.dropForeign('environment_id') + table.dropColumn('environment_id') + }) + } +} + +module.exports = UpdateUsersAddEnvAttrSchema diff --git a/src/adonisjs/database/schema_designs/v1_2_1/class_diagram.drawio b/src/adonisjs/database/schema_designs/v1_2_1/class_diagram.drawio new file mode 100644 index 0000000..31ba1dc --- /dev/null +++ b/src/adonisjs/database/schema_designs/v1_2_1/class_diagram.drawio @@ -0,0 +1 @@ +7V1bc6O4Ev41rtrzYAqJqx9zmZk9dWZnc5LZuexLSrGJzQaDB3AS768/EgYbiTYGjIhnj7JVOwZjAeqvu79utaSRcbV8/RCT1eK3aOYFI6zPXkfG9Qhj5Bo6/Yed2WzPWK67PTGP/Vl+0f7Enf+3l5/Mfzdf+zMv4S5MoyhI/RV/chqFoTdNuXMkjqMX/rLHKODvuiJzr3LibkqC6tmv/ixdbM+6lr4//6vnzxfFn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ZvSZbkqHnzeMdYd7kZG/gKHnssQXlC4nn7YPsJeMdrtKA7rSpUr3bLFNisKo5Io8pIojjBrsCipOrqsVB+VnDAsDgTPKe3W5D7wnr1ATQKpir5exc5yUSn4kWH+PMsEpqr5JIp+yDWl4EeGFxcqsWbazUQpfe+SH3JVKfiRq4OtdbQ5F2SJM2erdLN636zPZyRZZAcCnbY4Mn2ESG/h9DXvElznb8t0tlYkR/nsiUTVhmlca546Ngx+LMXl2jXF+cGteSuHlh64JK4G3hUAZbSspJkl+BwxCQ85T2usgTmcp1EY0rg/v+doR//bDHKN2gUwp2332SB6bdCL8dZinFE39tSL9DCOorQM3ZisFr9FM8ZJ3/0P \ No newline at end of file diff --git a/src/adonisjs/database/schema_designs/v2_0_0/class_diagram.drawio b/src/adonisjs/database/schema_designs/v2_0_0/class_diagram.drawio new file mode 100644 index 0000000..4f9a941 --- /dev/null +++ b/src/adonisjs/database/schema_designs/v2_0_0/class_diagram.drawio @@ -0,0 +1 @@ +7V1Zc6O4Fv41rpr7AIXYeXSWnrl1M92ZpNd5SSmG2ExjcANO4vn1V2KxkThmMxD3DJmqaSNjFp1P31klzZTL9euvId6sfg9sx5vJkv06U65msiyrpkL+oS27tMVS5LRhGbp22oQODffu307WKGWtW9d2IubEOAi82N2wjYvA951FzLThMAxe2NOeAo+96wYvnVLD/QJ75dYvrh2v0lZTkw7tvznucpXfGUnZN4948X0ZBls/u99MVp6Sv/TrNc6vlZ0frbAdvBSalOuZchkGQZx+Wr9eOh7t27zb0t+9O/Lt/rlDx4+b/MCLb58e1gv/1/fh3eevL99/Wz6/F1Qjvcwz9rZO/h7J08a7vIeeXM+7DLwgTA6Vq+tr8x25yUUUh8F3J//GD3yn/EjZUz47Yey8FpqyR/zVCdZOHO7IKdm3gmZm/bXLcZIdvxykg2Qra1wVRGPmkMIZJJb7qx+6hXzIegbupejT/PXux+17QdB+qJtvt/97uN8I+YWresnx7TmFIzlaeDiK3AXpItL4zqX3ukLpUYZ/nRyt4vX+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Znrqvx1WxuuDFx6MCZzA7YKQYldVhiaBfzUcMJjZqg1HoIZnheB7xPXP7vnbG//tzHQZu08mNP2dWvgvjboxTCljDPqxqF6EQwD6WXuIuM+d1sIwa+CZeBj7/rQyhHY4ZybgKqjpHf/cuJ4l7kveBsHXNQgd/EL/n3GeEede5CUaj37qqh3kQmP19ydyntt/WEkKQx9adnqhH25tyAKysbMTNY9Oixs95l8XNKPKG8jtyg0gwC6oauOwwNuQeRFwzOlEbcmZkmKL27UsmYJtTyaLGoOhOyOjc0iiI6PkqMDVhJNPd/Y+ESlaIkGmy4UkCJK3GWCp6fIiWf80K/EATkMgyAunh7izer3wKZyuv4/ \ No newline at end of file diff --git a/src/adonisjs/database/schema_designs/v2_0_0/class_diagram.jpg b/src/adonisjs/database/schema_designs/v2_0_0/class_diagram.jpg new file mode 100644 index 0000000..80c014e Binary files /dev/null and b/src/adonisjs/database/schema_designs/v2_0_0/class_diagram.jpg differ diff --git a/src/adonisjs/database/seeds/InitialSeeder.js b/src/adonisjs/database/seeds/InitialSeeder.js index 97e3c91..7e4fafd 100644 --- a/src/adonisjs/database/seeds/InitialSeeder.js +++ b/src/adonisjs/database/seeds/InitialSeeder.js @@ -23,6 +23,8 @@ const User = use('App/Models/v1/User') const Quest = use('App/Models/v1/Quest') const Artifact = use('App/Models/v1/Artifact') const Role = use('App/Models/v1/Role') +const Environment = use('App/Models/Environment') +const Permission = use('App/Models/v1/Permission') const fs = require('fs') const uuidv4 = require('uuid/v4') @@ -44,6 +46,8 @@ class UserSeeder { const user = await this.seed_default_users(trx) + const environment = await this.seed_environment(user, trx) + const institution = await this.seed_institution(user, trx) // console.log(institution) await user.save(trx) @@ -90,6 +94,50 @@ class UserSeeder { } } + async seed_environment(user, trx) { + try { + const environment = new Environment() + environment.id = await uuidv4() + environment.name = 'Harena' + + const environment2 = new Environment() + environment2.id = await uuidv4() + environment2.name = 'Jacinto' + + const environment3 = new Environment() + environment3.id = await uuidv4() + environment3.name = 'unicamp' + + const environment4 = new Environment() + environment4.id = await uuidv4() + environment4.name = 'ResidĂȘncia da Tarde' + + const environment5 = new Environment() + environment5.id = await uuidv4() + environment5.name = 'PĂșblico' + + + await environment.save(trx) + await environment2.save(trx) + await environment3.save(trx) + await environment4.save(trx) + await environment5.save(trx) + + + await user.environment().associate(environment, trx) + + // const permission = new Permission() + // permission.id = await uuidv4() + // permission.clearance = 4 + // permission.subject_grade = 'admin' + // permission.resource = 'cases' + // permission.resource_id = + return environment + } catch (e) { + console.log(e) + } + } + async seed_institution(user, trx) { try { const institution = new Institution() @@ -161,7 +209,7 @@ class UserSeeder { console.log('user---------------'+user) console.log(cv) - await c.versions().save([cv.id], trx) + await c.versions().save(cv, trx) console.log('salvoooooooooooooooooooooooooooooooooooooooooooooooou version') await c.institution().associate(institution, trx) console.log('c2--------------'+c) diff --git a/src/adonisjs/start/kernel.js b/src/adonisjs/start/kernel.js index c3f0ee3..2d56fb7 100644 --- a/src/adonisjs/start/kernel.js +++ b/src/adonisjs/start/kernel.js @@ -18,7 +18,7 @@ const globalMiddleware = [ 'Adonis/Middleware/Shield', 'Adonis/Middleware/AuthInit', 'App/Middleware/ConvertEmptyStringsToNull', - 'Adonis/Acl/Init' + 'Adonis/Acl/Init', ] /* @@ -43,8 +43,10 @@ const namedMiddleware = { guest: 'Adonis/Middleware/AllowGuestOnly', is: 'Adonis/Acl/Is', can: 'Adonis/Acl/Can', - case_permission: 'App/Middleware/CheckCasePermission', - quest_permission: 'App/Middleware/CheckQuestPermission' + permission: 'App/Middleware/CheckPermission', + + // case_permission: 'App/Middleware/CheckCasePermission', + // quest_permission: 'App/Middleware/CheckQuestPermission' } /* diff --git a/src/adonisjs/start/routes.js b/src/adonisjs/start/routes.js index e41166a..1870883 100644 --- a/src/adonisjs/start/routes.js +++ b/src/adonisjs/start/routes.js @@ -65,15 +65,23 @@ Route.group(() => { |---------------------------------------------------------------------------------------------- */ Route.group(() => { + // Route.put( ':id', 'v1/CaseController.update').middleware(['permission:cases']) + Route.post( '', 'v1/CaseController.store') - Route.put( '', 'v1/CaseController.update').middleware(['case_permission:write']) - Route.delete('', 'v1/CaseController.destroy').middleware(['case_permission:delete']) + + Route.put( ':id', 'v1/CaseController.update').middleware(['permission:cases,write']) + // Route.put( '', 'v1/CaseController.update').middleware(['case_permission:write']) + + Route.delete('', 'v1/CaseController.destroy').middleware(['permission:cases,delete']) + // Route.delete('', 'v1/CaseController.destroy').middleware(['case_permission:delete']) + Route.post('share', 'v1/CaseController.share').middleware(['case_permission:share']) Route.post('property', 'v1/CaseController.storeProperty').middleware(['auth', 'case_permission:write']) Route.put('property', 'v1/CaseController.updateProperty').middleware(['auth', 'case_permission:write']) }).prefix('/api/v1/case').middleware(['auth', 'is:author']) -Route.get( '/api/v1/case', 'v1/CaseController.show').middleware(['auth', 'case_permission:read']) +// Route.get( '/api/v1/case', 'v1/CaseController.show').middleware(['auth', 'case_permission:read']) +Route.get( '/api/v1/case', 'v1/CaseController.show').middleware(['auth', 'permission:cases,read']) /* @@ -200,6 +208,10 @@ Route.group(() => { Route.post( 'institution', 'v1/InstitutionController.store') + Route.post( 'permission', 'PermissionController.store') + + + Route.post( 'revoke_tokens', 'v1/AdminController.revoke_tokens') Route.put( 'user/:id', 'v1/AdminController.updateUser')