snipe-it/routes/web.php

506 lines
16 KiB
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
2017-01-13 00:13:57 -08:00
2021-06-10 13:17:14 -07:00
use App\Http\Controllers\Account;
use App\Http\Controllers\ActionlogController;
2021-06-10 13:19:27 -07:00
use App\Http\Controllers\CategoriesController;
use App\Http\Controllers\CompaniesController;
2021-06-10 13:17:14 -07:00
use App\Http\Controllers\DashboardController;
2021-06-10 13:19:27 -07:00
use App\Http\Controllers\DepartmentsController;
use App\Http\Controllers\DepreciationsController;
2021-06-10 13:17:14 -07:00
use App\Http\Controllers\GroupsController;
use App\Http\Controllers\HealthController;
use App\Http\Controllers\ImportsController;
use App\Http\Controllers\LocationsController;
use App\Http\Controllers\ManufacturersController;
use App\Http\Controllers\ModalController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ReportsController;
use App\Http\Controllers\SettingsController;
2021-06-10 13:19:27 -07:00
use App\Http\Controllers\StatuslabelsController;
use App\Http\Controllers\SuppliersController;
2021-06-10 13:17:14 -07:00
use App\Http\Controllers\ViewAssetsController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\ResetPasswordController;
2021-06-10 13:17:14 -07:00
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
2021-06-10 13:17:14 -07:00
Route::group(['middleware' => 'auth'], function () {
2017-05-22 21:31:47 -07:00
/*
* Companies
*/
2021-06-10 13:17:14 -07:00
Route::resource('companies', CompaniesController::class, [
'parameters' => ['company' => 'company_id'],
2017-05-22 21:31:47 -07:00
]);
/*
* Categories
*/
2021-06-10 13:17:14 -07:00
Route::resource('categories', CategoriesController::class, [
'parameters' => ['category' => 'category_id'],
2017-05-22 21:31:47 -07:00
]);
/*
* Locations
*/
2021-06-10 13:17:14 -07:00
Route::resource('locations', LocationsController::class, [
'parameters' => ['location' => 'location_id'],
2017-05-22 21:31:47 -07:00
]);
2019-03-09 00:14:24 -08:00
Route::get(
2019-05-03 05:22:05 -07:00
'locations/{locationId}/printassigned',
[LocationsController::class, 'print_assigned']
)->name('locations.print_assigned');
2019-03-09 00:14:24 -08:00
Route::get(
2019-05-03 05:22:05 -07:00
'locations/{locationId}/printallassigned',
[LocationsController::class, 'print_all_assigned']
)->name('locations.print_all_assigned');
2017-05-22 21:31:47 -07:00
/*
* Manufacturers
*/
Route::group(['prefix' => 'manufacturers', 'middleware' => ['auth']], function () {
Route::post('{manufacturers_id}/restore', [ManufacturersController::class, 'restore'] )->name('restore/manufacturer');
});
2021-06-10 13:17:14 -07:00
Route::resource('manufacturers', ManufacturersController::class, [
'parameters' => ['manufacturer' => 'manufacturers_id'],
2017-05-22 21:31:47 -07:00
]);
/*
* Suppliers
*/
2021-06-10 13:17:14 -07:00
Route::resource('suppliers', SuppliersController::class, [
'parameters' => ['supplier' => 'supplier_id'],
2017-05-22 21:31:47 -07:00
]);
/*
* Depreciations
*/
2021-06-10 13:17:14 -07:00
Route::resource('depreciations', DepreciationsController::class, [
'parameters' => ['depreciation' => 'depreciation_id'],
2017-05-22 21:31:47 -07:00
]);
/*
* Status Labels
*/
2021-06-10 13:17:14 -07:00
Route::resource('statuslabels', StatuslabelsController::class, [
'parameters' => ['statuslabel' => 'statuslabel_id'],
2017-05-22 21:31:47 -07:00
]);
/*
* Departments
*/
2021-06-10 13:17:14 -07:00
Route::resource('departments', DepartmentsController::class, [
'parameters' => ['department' => 'department_id'],
2017-05-22 21:31:47 -07:00
]);
});
/*
|
|--------------------------------------------------------------------------
| Re-Usable Modal Dialog routes.
|--------------------------------------------------------------------------
|
| Routes for various modal dialogs to interstitially create various things
|
*/
Route::group(['middleware' => 'auth', 'prefix' => 'modals'], function () {
Route::get('{type}/{itemId?}', [ModalController::class, 'show'] )->name('modal.show');
});
2017-01-13 00:13:57 -08:00
/*
|--------------------------------------------------------------------------
| Log Routes
|--------------------------------------------------------------------------
|
| Register all the admin routes.
|
*/
Route::group(['middleware' => 'auth'], function () {
Route::get(
'display-sig/{filename}',
[ActionlogController::class, 'displaySig']
)->name('log.signature.view');
Route::get(
'stored-eula-file/{filename}',
[ActionlogController::class, 'getStoredEula']
)->name('log.storedeula.download');
});
2016-03-25 01:18:05 -07:00
/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| Register all the admin routes.
|
*/
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser']], function () {
Route::get('settings', [SettingsController::class, 'getSettings'])->name('settings.general.index');
Route::post('settings', [SettingsController::class, 'postSettings'])->name('settings.general.save');
2016-03-25 01:18:05 -07:00
Route::get('branding', [SettingsController::class, 'getBranding'])->name('settings.branding.index');
Route::post('branding', [SettingsController::class, 'postBranding'])->name('settings.branding.save');
2016-08-02 00:54:38 -07:00
Route::get('security', [SettingsController::class, 'getSecurity'])->name('settings.security.index');
Route::post('security', [SettingsController::class, 'postSecurity'])->name('settings.security.save');
2016-03-25 01:18:05 -07:00
Route::get('groups', [GroupsController::class, 'index'])->name('settings.groups.index');
2016-07-13 05:50:40 -07:00
Route::get('localization', [SettingsController::class, 'getLocalization'])->name('settings.localization.index');
Route::post('localization', [SettingsController::class, 'postLocalization'])->name('settings.localization.save');
2016-07-13 05:50:40 -07:00
Route::get('notifications', [SettingsController::class, 'getAlerts'])->name('settings.alerts.index');
Route::post('notifications', [SettingsController::class, 'postAlerts'])->name('settings.alerts.save');
2016-03-25 01:18:05 -07:00
Route::get('slack', [SettingsController::class, 'getSlack'])->name('settings.slack.index');
Route::post('slack', [SettingsController::class, 'postSlack'])->name('settings.slack.save');
2016-07-13 05:50:40 -07:00
Route::get('asset_tags', [SettingsController::class, 'getAssetTags'])->name('settings.asset_tags.index');
Route::post('asset_tags', [SettingsController::class, 'postAssetTags'])->name('settings.asset_tags.save');
2016-07-13 05:50:40 -07:00
Route::get('barcodes', [SettingsController::class, 'getBarcodes'])->name('settings.barcodes.index');
Route::post('barcodes', [SettingsController::class, 'postBarcodes'])->name('settings.barcodes.save');
2016-03-25 01:18:05 -07:00
Route::get('labels', [SettingsController::class, 'getLabels'])->name('settings.labels.index');
Route::post('labels', [SettingsController::class, 'postLabels'])->name('settings.labels.save');
2016-03-25 01:18:05 -07:00
Route::get('ldap', [SettingsController::class, 'getLdapSettings'])->name('settings.ldap.index');
Route::post('ldap', [SettingsController::class, 'postLdapSettings'])->name('settings.ldap.save');
2016-03-25 01:18:05 -07:00
Route::get('phpinfo', [SettingsController::class, 'getPhpInfo'])->name('settings.phpinfo.index');
2016-03-25 01:18:05 -07:00
Route::get('oauth', [SettingsController::class, 'api'])->name('settings.oauth.index');
2017-07-07 23:44:48 -07:00
Route::get('purge', [SettingsController::class, 'getPurge'])->name('settings.purge.index');
Route::post('purge', [SettingsController::class, 'postPurge'])->name('settings.purge.save');
2017-07-07 23:44:48 -07:00
Route::get('login-attempts', [SettingsController::class, 'getLoginAttempts'])->name('settings.logins.index');
2017-07-07 23:44:48 -07:00
// Backups
Route::group(['prefix' => 'backups', 'middleware' => 'auth'], function () {
Route::get('download/{filename}',
[SettingsController::class, 'downloadFile'])->name('settings.backups.download');
2017-07-07 23:44:48 -07:00
Route::delete('delete/{filename}',
[SettingsController::class, 'deleteFile'])->name('settings.backups.destroy');
2017-07-07 23:44:48 -07:00
Route::post('/',
[SettingsController::class, 'postBackups']
)->name('settings.backups.create');
2017-07-07 23:44:48 -07:00
Route::post('/restore/{filename}',
[SettingsController::class, 'postRestore']
)->name('settings.backups.restore');
Route::post('/upload',
[SettingsController::class, 'postUploadBackup']
)->name('settings.backups.upload');
Route::get('/', [SettingsController::class, 'getBackups'])->name('settings.backups.index');
2016-03-25 01:18:05 -07:00
});
2021-06-10 13:17:14 -07:00
Route::resource('groups', GroupsController::class, [
2017-10-17 21:43:57 -07:00
'middleware' => ['auth'],
'parameters' => ['group' => 'group_id'],
2017-10-17 21:43:57 -07:00
]);
2017-07-07 23:44:48 -07:00
Route::get('/', [SettingsController::class, 'index'])->name('settings.index');
2016-03-25 01:18:05 -07:00
});
Importer mapping - v1 (#3677) * Move importer to an inline-template, allows for translations and easier passing of data from laravel to vue. * Pull the modal out into a dedicated partial, move importer to views/importer. * Add document of CSV->importer mappings. Reorganize some code. Progress. * Add header_row and first_row to imports table, and process upon uploading a file * Use an expandable table row instead of a modal for import processing. This should allow for field mapping interaction easier. * Fix import processing after moving method. * Frontend importer mapping improvements. Invert display so we show found columns and allow users to select an importer field to map to. Also implement sample data based on first row of csv. * Update select2. Maintain selected items properly. * Backend support for importing. Only works on the web importer currently. Definitely needs testing and polish. * We no longer use vue-modal plugin. * Add a column to track field mappings to the imports table. * Cleanup/rename methods+refactor * Save field mappings and import type when attempting an import, and repopulate these values when returning to the page. * Update debugbar to fix a bug in the debugbar code. * Fix asset tag detection. Also rename findMatch to be a bit clearer as to what it does. Remove logging to file of imports for http imports because it eats an incredible amouint of memory. This commit also moves imports out of the hardware namespace and into their own webcontroller and route prefix, remove dead code from AssetController as a result. * Dynamically limit options for select2 based on import type selected, and group them by item type. * Add user importer. Still need to implement emailing of passwords to new users, and probably test a bit more. This also bumps the memory limit for web imports up as well, I need to profile memory usage here before too long. * Query the db to find user matches rather than search the array. Performance is much much better. * Speed/memory improvements in importers. Move to querying the db rather than maintaining an array for all importers. Also only store the id of items when we import, rather than the full model. It saves a decent amount of memory. * Remove grouping of items in select2 With the values being set dynamically, the grouping is redundant. It also caused a regression with automatically guessing/matching field names. This is starting to get close. * Remove debug line on every create. * Switch migration to be text field instead of json field for compatibility with older mysql/mariadb * Fix asset import regression matching email address. * Rearrange travis order in attempt to fix null settings. * Use auth::id instead of fetching it off the user. Fixes a null object reference during seeding.
2017-06-21 16:37:37 -07:00
/*
|--------------------------------------------------------------------------
| Importer Routes
|--------------------------------------------------------------------------
|
|
|
*/
Route::group(['prefix' => 'import', 'middleware' => ['auth']], function () {
Route::get('/',
[ImportsController::class, 'index']
)->name('imports.index');
Importer mapping - v1 (#3677) * Move importer to an inline-template, allows for translations and easier passing of data from laravel to vue. * Pull the modal out into a dedicated partial, move importer to views/importer. * Add document of CSV->importer mappings. Reorganize some code. Progress. * Add header_row and first_row to imports table, and process upon uploading a file * Use an expandable table row instead of a modal for import processing. This should allow for field mapping interaction easier. * Fix import processing after moving method. * Frontend importer mapping improvements. Invert display so we show found columns and allow users to select an importer field to map to. Also implement sample data based on first row of csv. * Update select2. Maintain selected items properly. * Backend support for importing. Only works on the web importer currently. Definitely needs testing and polish. * We no longer use vue-modal plugin. * Add a column to track field mappings to the imports table. * Cleanup/rename methods+refactor * Save field mappings and import type when attempting an import, and repopulate these values when returning to the page. * Update debugbar to fix a bug in the debugbar code. * Fix asset tag detection. Also rename findMatch to be a bit clearer as to what it does. Remove logging to file of imports for http imports because it eats an incredible amouint of memory. This commit also moves imports out of the hardware namespace and into their own webcontroller and route prefix, remove dead code from AssetController as a result. * Dynamically limit options for select2 based on import type selected, and group them by item type. * Add user importer. Still need to implement emailing of passwords to new users, and probably test a bit more. This also bumps the memory limit for web imports up as well, I need to profile memory usage here before too long. * Query the db to find user matches rather than search the array. Performance is much much better. * Speed/memory improvements in importers. Move to querying the db rather than maintaining an array for all importers. Also only store the id of items when we import, rather than the full model. It saves a decent amount of memory. * Remove grouping of items in select2 With the values being set dynamically, the grouping is redundant. It also caused a regression with automatically guessing/matching field names. This is starting to get close. * Remove debug line on every create. * Switch migration to be text field instead of json field for compatibility with older mysql/mariadb * Fix asset import regression matching email address. * Rearrange travis order in attempt to fix null settings. * Use auth::id instead of fetching it off the user. Fixes a null object reference during seeding.
2017-06-21 16:37:37 -07:00
});
2016-03-25 01:18:05 -07:00
/*
|--------------------------------------------------------------------------
| Account Routes
|--------------------------------------------------------------------------
|
|
|
*/
Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
2016-03-25 01:18:05 -07:00
// Profile
Route::get('profile', [ProfileController::class, 'getIndex'])->name('profile');
2021-06-10 13:17:14 -07:00
Route::post('profile', [ProfileController::class, 'postIndex']);
Route::get('menu', [ProfileController::class, 'getMenuState'])->name('account.menuprefs');
2017-10-25 20:15:30 -07:00
Route::get('password', [ProfileController::class, 'password'])->name('account.password.index');
Route::post('password', [ProfileController::class, 'passwordSave']);
Route::get('api', [ProfileController::class, 'api'])->name('user.api');
2017-01-11 03:38:55 -08:00
// View Assets
Route::get('view-assets', [ViewAssetsController::class, 'getIndex'])->name('view-assets');
2016-03-25 01:18:05 -07:00
Route::get('requested', [ViewAssetsController::class, 'getRequestedAssets'])->name('account.requested');
WIP - Improved requested assets (#5289) * WIP - beginning of improved requested assets - Use Ajax tables for faster loading - Use new notifications for requesting an asset TODO: - Use ajax tables for requestable asset models - Use new notifications for canceling an asset request - Expire requests once the asset has been checked out to the requesting user * Only show asset name in email if it has one * Refactor requested method to only include non-canceled requests * Refactored requestable assets to log request and cancelation * Added softdeletes on checkout requests * Differentiate between canceling and deleting requests * Added asset request cancelation notification * Added timestamps and corrected unique key on requests table * Improved requests view * Re-use blade for cancel/request email * Refactored BS table formatter for requested assets * Location name min reduced to 2 * Added PAT test as maintenance option This needs to be refactored into database-driven options with a UI * Better slack message * Added getImageUrl method for assets * Include qty in request notifications TODO: - Try to pull requested info from original request for cancelation, otherwise it will default to 1 * Removed old asset request/cancel emails * Added user profile asset request routes * Added profile controller requested assets method * Added blade link to requested assets for profile view * Sort user history desc * Added requested assets blade * Added canceled at to checkoutRequest method * Include qty in request * Fixed comment, removed allowed_columns * Removed Queable methods, since we don’t use a queue * Fixed return type in method doc * Fixed version number * Changed id to user_id for clarity
2018-04-04 17:33:02 -07:00
// Profile
2016-03-25 01:18:05 -07:00
Route::get(
'requestable-assets',
[ViewAssetsController::class, 'getRequestableIndex']
)->name('requestable-assets');
Route::post(
2016-03-25 01:18:05 -07:00
'request-asset/{assetId}',
[ViewAssetsController::class, 'getRequestAsset']
)->name('account/request-asset');
2016-03-25 01:18:05 -07:00
Route::post(
'request/{itemType}/{itemId}',
[ViewAssetsController::class, 'getRequestItem']
)->name('account/request-item');
// Account Dashboard
Route::get('/', [ViewAssetsController::class, 'getIndex'])->name('account');
2021-06-10 13:17:14 -07:00
Route::get('accept', [Account\AcceptanceController::class, 'index'])
->name('account.accept');
Route::get('accept/{id}', [Account\AcceptanceController::class, 'create'])
->name('account.accept.item');
2021-06-10 13:17:14 -07:00
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store']);
Route::get(
'print',
[
ProfileController::class,
'printInventory'
]
)->name('profile.print');
Route::post(
'email',
[
ProfileController::class,
'emailAssetList'
]
)->name('profile.email_assets');
2016-03-25 01:18:05 -07:00
});
Route::group(['middleware' => ['auth']], function () {
Route::get('reports/audit',
[ReportsController::class, 'audit']
)->name('reports.audit');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/depreciation',
[ReportsController::class, 'getDeprecationReport']
)->name('reports/depreciation');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/export/depreciation',
[ReportsController::class, 'exportDeprecationReport']
)->name('reports/export/depreciation');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/asset_maintenances',
[ReportsController::class, 'getAssetMaintenancesReport']
)->name('reports/asset_maintenances');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/export/asset_maintenances',
[ReportsController::class, 'exportAssetMaintenancesReport']
)->name('reports/export/asset_maintenances');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/licenses',
[ReportsController::class, 'getLicenseReport']
)->name('reports/licenses');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/export/licenses',
[ReportsController::class, 'exportLicenseReport']
)->name('reports/export/licenses');
2018-05-02 14:13:06 -07:00
Route::get('reports/accessories', [ReportsController::class, 'getAccessoryReport'])->name('reports/accessories');
2016-03-25 01:18:05 -07:00
Route::get(
'reports/export/accessories',
[ReportsController::class, 'exportAccessoryReport']
)->name('reports/export/accessories');
Route::get('reports/custom', [ReportsController::class, 'getCustomReport'])->name('reports/custom');
2021-06-10 13:17:14 -07:00
Route::post('reports/custom', [ReportsController::class, 'postCustom']);
2016-03-25 01:18:05 -07:00
Route::get(
'reports/activity',
[ReportsController::class, 'getActivityReport']
)->name('reports.activity');
2016-09-19 23:52:01 -07:00
2021-06-10 13:17:14 -07:00
Route::post('reports/activity', [ReportsController::class, 'postActivityReport']);
2016-03-25 01:18:05 -07:00
Route::get(
'reports/unaccepted_assets/{deleted?}',
[ReportsController::class, 'getAssetAcceptanceReport']
)->name('reports/unaccepted_assets');
Route::get(
'reports/unaccepted_assets/{acceptanceId}/sent_reminder',
[ReportsController::class, 'sentAssetAcceptanceReminder']
)->name('reports/unaccepted_assets_sent_reminder');
Route::delete(
'reports/unaccepted_assets/{acceptanceId}/delete',
[ReportsController::class, 'deleteAssetAcceptance']
)->name('reports/unaccepted_assets_delete');
Route::post(
'reports/unaccepted_assets/{deleted?}',
2021-10-07 12:32:57 -07:00
[ReportsController::class, 'postAssetAcceptanceReport']
)->name('reports/export/unaccepted_assets');
2016-03-25 01:18:05 -07:00
});
2017-02-02 18:14:25 -08:00
Route::get(
'auth/signin',
[LoginController::class, 'legacyAuthRedirect']
2017-02-02 18:14:25 -08:00
);
2016-03-25 01:18:05 -07:00
/*
|--------------------------------------------------------------------------
| Setup Routes
|--------------------------------------------------------------------------
|
|
|
*/
Route::group(['prefix' => 'setup', 'middleware' => 'web'], function () {
2016-03-25 01:18:05 -07:00
Route::get(
'user',
[SettingsController::class, 'getSetupUser']
)->name('setup.user');
2016-03-25 01:18:05 -07:00
Route::post(
'user',
[SettingsController::class, 'postSaveFirstAdmin']
)->name('setup.user.save');
2016-03-25 01:18:05 -07:00
Route::get(
'migrate',
[SettingsController::class, 'getSetupMigrate']
)->name('setup.migrate');
2016-03-25 01:18:05 -07:00
Route::get(
'done',
[SettingsController::class, 'getSetupDone']
)->name('setup.done');
2016-03-25 01:18:05 -07:00
Route::get(
'mailtest',
[SettingsController::class, 'ajaxTestEmail']
)->name('setup.mailtest');
2016-03-25 01:18:05 -07:00
Route::get(
'/',
[SettingsController::class, 'getSetupIndex']
)->name('setup');
2016-03-25 01:18:05 -07:00
});
2016-03-25 01:18:05 -07:00
2016-03-25 01:18:05 -07:00
Route::group(['middleware' => 'web'], function () {
Route::get(
'login',
[LoginController::class, 'showLoginForm']
)->name("login");
Route::post(
'login',
[LoginController::class, 'login']
);
Route::get(
'two-factor-enroll',
[LoginController::class, 'getTwoFactorEnroll']
)->name('two-factor-enroll');
Route::get(
'two-factor',
[LoginController::class, 'getTwoFactorAuth']
)->name('two-factor');
Route::post(
'two-factor',
[LoginController::class, 'postTwoFactorAuth']
);
Route::post(
'password/email',
[ForgotPasswordController::class, 'sendResetLinkEmail']
)->name('password.email')->middleware('throttle:forgotten_password');
Route::get(
'password/reset',
[ForgotPasswordController::class, 'showLinkRequestForm']
)->name('password.request')->middleware('throttle:forgotten_password');
Route::post(
'password/reset',
[ResetPasswordController::class, 'reset']
)->name('password.update')->middleware('throttle:forgotten_password');
Route::get(
'password/reset/{token}',
[ResetPasswordController::class, 'showResetForm']
)->name('password.reset');
Route::post(
'password/email',
[ForgotPasswordController::class, 'sendResetLinkEmail']
)->name('password.email')->middleware('throttle:forgotten_password');
Route::get(
'/',
[
'as' => 'home',
'middleware' => ['auth'],
'uses' => 'DashboardController@getIndex' ]
);
2022-05-14 04:59:34 -07:00
// need to keep GET /logout for SAML SLO
Route::get(
'logout',
[LoginController::class, 'logout']
)->name('logout.get');
2022-05-14 04:59:34 -07:00
Route::post(
'logout',
[LoginController::class, 'logout']
)->name('logout.post');
2016-03-25 01:18:05 -07:00
});
//Auth::routes();
2017-05-09 00:37:37 -07:00
Route::get(
'/health',
[HealthController::class, 'get']
)->name('health');
Route::middleware(['auth'])->get(
'/',
[DashboardController::class, 'index']
)->name('home');