2023-03-03 15:54:28 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| This file is dedicated for defining HTTP routes. A single file is enough
|
|
|
|
| for majority of projects, however you can define routes in different
|
|
|
|
| files and just make sure to import them inside this file. For example
|
|
|
|
|
|
|
|
|
| Define routes in following two files
|
|
|
|
| ├── start/routes/cart.ts
|
|
|
|
| ├── start/routes/customer.ts
|
|
|
|
|
|
|
|
|
| and then import them inside `start/routes.ts` as follows
|
|
|
|
|
|
|
|
|
| import './routes/cart'
|
|
|
|
| import './routes/customer''
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Route from '@ioc:Adonis/Core/Route';
|
|
|
|
// import Inertia from '@ioc:EidelLev/Inertia';
|
|
|
|
import AuthValidator from 'App/Validators/AuthValidator';
|
|
|
|
import HealthCheck from '@ioc:Adonis/Core/HealthCheck';
|
|
|
|
import User from 'App/Models/User';
|
|
|
|
// import AuthController from 'App/Controllers/Http/Auth/AuthController';
|
|
|
|
import './routes/api';
|
|
|
|
|
|
|
|
Route.get('health', async ({ response }) => {
|
|
|
|
const report = await HealthCheck.getReport();
|
|
|
|
return report.healthy ? response.ok(report) : response.badRequest(report);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2023-12-01 09:44:19 +00:00
|
|
|
//oai:
|
2023-07-17 17:13:30 +00:00
|
|
|
// Route.get( '/oai', 'Oai/RequestController.index').as('oai');
|
|
|
|
Route.group(() => {
|
|
|
|
Route.get('/oai', 'Oai/OaiController.index').as('get');
|
|
|
|
Route.post('/oai', 'Oai/OaiController.index').as('post');
|
|
|
|
}).as('oai');
|
2023-03-03 15:54:28 +00:00
|
|
|
// Route.inertia('/about', 'App');
|
|
|
|
|
2023-12-01 09:44:19 +00:00
|
|
|
//old solution:
|
|
|
|
// Route.get('/', async ({ view }) => {
|
|
|
|
// return view.render('welcome');
|
|
|
|
// }).as('dashboard2');
|
|
|
|
|
|
|
|
Route.get('/', async ({ response }) => {
|
2023-12-12 14:22:25 +00:00
|
|
|
return response.redirect().toRoute('apps.dashboard');
|
2023-12-01 09:44:19 +00:00
|
|
|
}).as('dashboard');
|
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
Route.group(() => {
|
2023-12-01 09:44:19 +00:00
|
|
|
Route.get('/dashboard', async ({ inertia }) => {
|
|
|
|
return inertia.render('Dashboard');
|
|
|
|
}).as('dashboard');
|
|
|
|
|
2023-12-15 16:17:33 +00:00
|
|
|
Route.get('/map', async ({ inertia }) => {
|
|
|
|
return inertia.render('Map');
|
|
|
|
}).as('map');
|
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
Route.get('/', async ({ inertia }) => {
|
|
|
|
const users = await User.query().orderBy('login');
|
|
|
|
return inertia.render('App', {
|
|
|
|
testing: 'this is a test',
|
|
|
|
users: users,
|
|
|
|
});
|
|
|
|
}).as('index');
|
|
|
|
|
|
|
|
// Route.get('/login', async ({ inertia }) => {
|
|
|
|
// return inertia.render('Auth/Login');
|
|
|
|
// }).as('login.show');
|
|
|
|
|
|
|
|
Route.get('/register', async ({ inertia }) => {
|
|
|
|
return inertia.render('register-view/register-view-component');
|
|
|
|
}).as('register.show');
|
|
|
|
|
|
|
|
Route.post('/register', async ({ request, response }) => {
|
|
|
|
console.log({
|
|
|
|
registerBody: request.body(),
|
|
|
|
});
|
|
|
|
|
|
|
|
const data = await request.validate(AuthValidator);
|
|
|
|
console.log({ data });
|
|
|
|
|
|
|
|
return response.redirect().toRoute('app.index');
|
|
|
|
}).as('register.store');
|
|
|
|
})
|
2023-12-12 14:22:25 +00:00
|
|
|
.prefix('apps')
|
|
|
|
.as('apps')
|
2023-03-03 15:54:28 +00:00
|
|
|
.middleware('auth');
|
|
|
|
|
2023-12-15 16:17:33 +00:00
|
|
|
|
2023-10-20 13:26:25 +00:00
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
// Route.on("/login").render("signin");
|
|
|
|
Route.get('/app/login', async ({ inertia }) => {
|
|
|
|
return inertia.render('Auth/Login');
|
|
|
|
}).as('app.login.show');
|
|
|
|
|
|
|
|
// Route.post("/login", "Users/AuthController.login");
|
|
|
|
Route.post('/app/login', 'Auth/AuthController.login').as('login.store');
|
|
|
|
// Route.on("/signup").render("signup");
|
|
|
|
// Route.post("/signup", "AuthController.signup");
|
|
|
|
Route.post('/signout', 'Auth/AuthController.logout').as('logout');
|
|
|
|
|
2023-11-27 16:17:22 +00:00
|
|
|
// administrator
|
2023-03-03 15:54:28 +00:00
|
|
|
Route.group(() => {
|
|
|
|
Route.get('/settings', async ({ inertia }) => {
|
|
|
|
return inertia.render('Admin/Settings');
|
2023-12-15 16:17:33 +00:00
|
|
|
|
|
|
|
}).as('overview');
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-04-06 16:56:41 +00:00
|
|
|
Route.get('/user', 'UsersController.index').as('user.index').middleware(['can:user-list']);
|
|
|
|
Route.get('/user/create', 'UsersController.create').as('user.create').middleware(['can:user-create']);
|
|
|
|
Route.post('/user/store', 'UsersController.store').as('user.store').middleware(['can:user-create']);
|
2023-03-03 15:54:28 +00:00
|
|
|
Route.get('/user/:id', 'UsersController.show').as('user.show').where('id', Route.matchers.number());
|
2023-04-06 16:56:41 +00:00
|
|
|
Route.get('/user/:id/edit', 'UsersController.edit').as('user.edit').where('id', Route.matchers.number()).middleware(['can:user-edit']);
|
2023-06-01 12:29:56 +00:00
|
|
|
Route.put('/user/:id/update', 'UsersController.update')
|
|
|
|
.as('user.update')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['can:user-edit']);
|
|
|
|
Route.delete('/user/:id', 'UsersController.destroy')
|
|
|
|
.as('user.destroy')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['can:user-delete']);
|
2023-03-03 15:54:28 +00:00
|
|
|
// Route.resource('user', 'UsersController');
|
|
|
|
|
2023-04-06 16:56:41 +00:00
|
|
|
Route.get('/role', 'RoleController.index').as('role.index').middleware(['can:user-list']);
|
|
|
|
Route.get('/role/create', 'RoleController.create').as('role.create').middleware(['can:user-create']);
|
|
|
|
Route.post('/role/store', 'RoleController.store').as('role.store').middleware(['can:user-create']);
|
2023-03-03 15:54:28 +00:00
|
|
|
Route.get('/role/:id', 'RoleController.show').as('role.show').where('id', Route.matchers.number());
|
2023-04-06 16:56:41 +00:00
|
|
|
Route.get('/role/:id/edit', 'RoleController.edit').as('role.edit').where('id', Route.matchers.number()).middleware(['can:user-edit']);
|
2023-06-01 12:29:56 +00:00
|
|
|
Route.put('/role/:id/update', 'RoleController.update')
|
|
|
|
.as('role.update')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['can:user-edit']);
|
|
|
|
Route.delete('/role/:id', 'RoleController.destroy')
|
|
|
|
.as('role.destroy')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['can:user-delete']);
|
2023-03-03 15:54:28 +00:00
|
|
|
})
|
|
|
|
.namespace('App/Controllers/Http/Admin')
|
|
|
|
.prefix('admin')
|
2023-12-15 16:17:33 +00:00
|
|
|
.as('settings')
|
2023-03-03 15:54:28 +00:00
|
|
|
// .middleware(['auth', 'can:dataset-list,dataset-publish']);
|
|
|
|
.middleware(['auth', 'is:administrator,moderator']);
|
|
|
|
|
2023-12-29 14:54:49 +00:00
|
|
|
|
|
|
|
Route.get('/settings/user/security', 'UserController.accountInfo')
|
2023-12-01 09:44:19 +00:00
|
|
|
.as('settings.user')
|
2023-12-29 14:54:49 +00:00
|
|
|
.namespace('App/Controllers/Http/Auth')
|
2023-03-03 15:54:28 +00:00
|
|
|
.middleware(['auth']);
|
|
|
|
|
2023-12-12 14:22:25 +00:00
|
|
|
Route.post('/settings/user/store', 'UsersController.accountInfoStore')
|
2023-12-29 14:54:49 +00:00
|
|
|
.as('account.password.store')
|
2023-03-03 15:54:28 +00:00
|
|
|
.namespace('App/Controllers/Http/Admin')
|
|
|
|
.middleware(['auth']);
|
|
|
|
// Route::post('change-password', 'UserController@changePasswordStore')->name('admin.account.password.store');
|
2023-03-17 15:13:37 +00:00
|
|
|
|
2023-12-29 14:54:49 +00:00
|
|
|
Route.post('/settings/user/enable2fa', 'UserController.enableTwoFactorAuthentication')
|
|
|
|
.as('account.password.enable2fa')
|
|
|
|
.namespace('App/Controllers/Http/Auth')
|
|
|
|
.middleware(['auth']);
|
|
|
|
|
|
|
|
Route.post('/settings/user/disable2fa', 'UserController.disableTwoFactorAuthentication')
|
|
|
|
.as('account.password.disable2fa')
|
|
|
|
.namespace('App/Controllers/Http/Auth')
|
|
|
|
.middleware(['auth']);
|
|
|
|
|
2023-11-27 16:17:22 +00:00
|
|
|
// submitter:
|
2023-03-17 15:13:37 +00:00
|
|
|
Route.group(() => {
|
|
|
|
// Route.get('/user', 'UsersController.index').as('user.index');
|
2023-11-27 16:17:22 +00:00
|
|
|
Route.get('/dataset', 'DatasetController.index').as('dataset.list').middleware(['auth', 'can:dataset-list']);
|
2023-03-17 15:13:37 +00:00
|
|
|
Route.get('/dataset/create', 'DatasetController.create').as('dataset.create').middleware(['auth', 'can:dataset-submit']);
|
|
|
|
Route.post('/dataset/first/first-step', 'DatasetController.firstStep')
|
|
|
|
.as('dataset.first.step')
|
|
|
|
.middleware(['auth', 'can:dataset-submit']);
|
|
|
|
Route.post('/dataset/second/second-step', 'DatasetController.secondStep')
|
|
|
|
.as('dataset.second.step')
|
|
|
|
.middleware(['auth', 'can:dataset-submit']);
|
2023-06-01 12:29:56 +00:00
|
|
|
Route.post('/dataset/second/third-step', 'DatasetController.thirdStep')
|
2023-03-24 10:41:52 +00:00
|
|
|
.as('dataset.third.step')
|
|
|
|
.middleware(['auth', 'can:dataset-submit']);
|
2023-06-16 14:44:28 +00:00
|
|
|
Route.post('/dataset/submit', 'DatasetController.store').as('dataset.submit').middleware(['auth', 'can:dataset-submit']);
|
2023-06-01 12:29:56 +00:00
|
|
|
|
2023-06-27 16:23:18 +00:00
|
|
|
Route.get('/dataset/:id/release', 'DatasetController.release')
|
|
|
|
.as('dataset.release')
|
|
|
|
.where('id', Route.matchers.number())
|
2023-11-27 16:17:22 +00:00
|
|
|
.middleware(['auth', 'can:dataset-edit']);
|
2023-06-27 16:23:18 +00:00
|
|
|
Route.put('/dataset/:id/releaseupdate', 'DatasetController.releaseUpdate')
|
|
|
|
.as('dataset.releaseUpdate')
|
2023-11-27 16:17:22 +00:00
|
|
|
.middleware(['auth', 'can:dataset-edit']);
|
2023-07-17 17:13:30 +00:00
|
|
|
Route.get('/dataset/:id/edit', 'DatasetController.edit')
|
|
|
|
.as('dataset.edit')
|
|
|
|
.where('id', Route.matchers.number())
|
2023-11-27 16:17:22 +00:00
|
|
|
.middleware(['auth', 'can:dataset-edit']);
|
2023-11-22 16:06:55 +00:00
|
|
|
Route.put('/dataset/:id/update', 'DatasetController.update')
|
2023-11-30 12:40:32 +00:00
|
|
|
.as('dataset.update')
|
2023-11-22 16:06:55 +00:00
|
|
|
.where('id', Route.matchers.number())
|
2023-11-27 16:17:22 +00:00
|
|
|
.middleware(['auth', 'can:dataset-edit']);
|
2023-11-30 12:40:32 +00:00
|
|
|
|
2023-09-05 16:18:42 +00:00
|
|
|
Route.get('/dataset/:id/delete', 'DatasetController.delete').as('dataset.delete').middleware(['auth', 'can:dataset-delete']);
|
|
|
|
Route.put('/dataset/:id/deleteupdate', 'DatasetController.deleteUpdate')
|
|
|
|
.as('dataset.deleteUpdate')
|
|
|
|
.middleware(['auth', 'can:dataset-delete']);
|
2023-06-27 16:23:18 +00:00
|
|
|
|
2023-09-14 13:37:36 +00:00
|
|
|
Route.get('/person', 'PersonController.index').as('person.index').middleware(['auth']);
|
2023-12-15 16:17:33 +00:00
|
|
|
// Route.get('/user/:id/edit', 'UsersController.edit').as('settings.user.edit').where('id', Route.matchers.number());
|
2023-03-17 15:13:37 +00:00
|
|
|
// Route.put('/user/:id/update', 'UsersController.update').as('user.update').where('id', Route.matchers.number());
|
|
|
|
// Route.delete('/user/:id', 'UsersController.destroy').as('user.destroy').where('id', Route.matchers.number());
|
|
|
|
// Route.resource('user', 'DatasetController');
|
|
|
|
})
|
|
|
|
.namespace('App/Controllers/Http/Submitter')
|
|
|
|
.prefix('submitter');
|
|
|
|
// .middleware(['auth', 'can:dataset-list,dataset-publish']);
|
|
|
|
// .middleware(['auth', 'is:submitter']);
|
2023-10-17 13:45:41 +00:00
|
|
|
|
2023-11-30 12:40:32 +00:00
|
|
|
// editor:
|
2023-10-17 13:45:41 +00:00
|
|
|
Route.group(() => {
|
2023-11-30 12:40:32 +00:00
|
|
|
Route.get('/dataset', 'DatasetController.index').as('editor.dataset.list').middleware(['auth', 'can:dataset-editor-list']);
|
|
|
|
Route.get('dataset/:id/receive', 'DatasetController.receive')
|
|
|
|
.as('editor.dataset.receive')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-receive']);
|
2023-12-12 14:22:25 +00:00
|
|
|
Route.put('dataset/:id/receive', 'DatasetController.receiveUpdate')
|
|
|
|
.as('editor.dataset.receiveUpdate')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-receive']);
|
|
|
|
Route.get('dataset/:id/approve', 'DatasetController.approve')
|
|
|
|
.as('editor.dataset.approve')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-approve']);
|
|
|
|
Route.put('dataset/:id/approve', 'DatasetController.approveUpdate')
|
|
|
|
.as('editor.dataset.approveUpdate')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-approve']);
|
2024-01-04 15:40:05 +00:00
|
|
|
|
|
|
|
Route.get('dataset/:id/publish', 'DatasetController.publish')
|
|
|
|
.as('editor.dataset.publish')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-publish']);
|
|
|
|
Route.put('dataset/:id/publish', 'DatasetController.publishUpdate')
|
|
|
|
.as('editor.dataset.publishUpdate')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-publish']);
|
2024-01-26 08:39:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
Route.get('dataset/:id/doi', 'DatasetController.doiCreate')
|
|
|
|
.as('editor.dataset.doi')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-publish']);
|
|
|
|
Route.put('dataset/:publish_id/doi', 'DatasetController.doiStore')
|
|
|
|
.as('editor.dataset.doiStore')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-publish']);
|
2023-11-30 12:40:32 +00:00
|
|
|
|
|
|
|
Route.put('/dataset/:id/update', 'DatasetController.update')
|
|
|
|
.as('editor.dataset.update')
|
|
|
|
.middleware(['auth', 'can:dataset-editor-edit']);
|
2023-10-17 13:45:41 +00:00
|
|
|
})
|
2023-10-20 13:26:25 +00:00
|
|
|
.namespace('App/Controllers/Http/Editor')
|
|
|
|
.prefix('editor');
|
2024-01-04 15:40:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
// reviewer:
|
|
|
|
Route.group(() => {
|
|
|
|
Route.get('/dataset', 'DatasetController.index').as('reviewer.dataset.list').middleware(['auth', 'can:dataset-review-list']);
|
|
|
|
Route.get('dataset/:id/review', 'DatasetController.review')
|
|
|
|
.as('reviewer.dataset.review')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-review']);
|
|
|
|
Route.put('dataset/:id/review', 'DatasetController.reviewUpdate')
|
|
|
|
.as('reviewer.dataset.reviewUpdate')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-review']);
|
|
|
|
Route.get('dataset/:id/reject', 'DatasetController.reject')
|
|
|
|
.as('reviewer.dataset.reject')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-review-reject']);
|
|
|
|
Route.put('dataset/:id/reject', 'DatasetController.rejectUpdate')
|
|
|
|
.as('reviewer.dataset.rejectUpdate')
|
|
|
|
.where('id', Route.matchers.number())
|
|
|
|
.middleware(['auth', 'can:dataset-review-reject']);
|
|
|
|
// Route.put('dataset/:id/approve', 'DatasetController.approveUpdate')
|
|
|
|
// .as('editor.dataset.approveUpdate')
|
|
|
|
// .where('id', Route.matchers.number())
|
|
|
|
// .middleware(['auth', 'can:dataset-approve']);
|
|
|
|
|
|
|
|
// Route.put('/dataset/:id/update', 'DatasetController.update')
|
|
|
|
// .as('editor.dataset.update')
|
|
|
|
// .middleware(['auth', 'can:dataset-editor-edit']);
|
|
|
|
})
|
|
|
|
.namespace('App/Controllers/Http/Reviewer')
|
|
|
|
.prefix('reviewer');
|