Files
librenms-librenms/includes/html/pages/alert-transports.inc.php
Neil Lathwood 95970af78e Moved some pages to be within admin route (#13782)
* Moved plugin admin pages to be within admin route
* Wrap html transports page in admin check
* Moved Port group controller to be admin protected
* fixed tests
2022-02-14 08:40:30 +01:00

34 lines
1.2 KiB
PHP

<?php
if (Auth::user()->hasGlobalAdmin()) {
// handle OAuth requests
$request = request(); // grab the Request object
if ($request->has('oauthtransport')) {
// make sure transport is safe
$validator = Validator::make($request->all(), ['oauthtransport' => 'required|alpha']);
if ($validator->passes()) {
$transport_name = $request->get('oauthtransport');
$class = \LibreNMS\Alert\Transport::getClass($transport_name);
if (class_exists($class)) {
$transport = app($class);
if ($transport->handleOauth($request)) {
flash()->addSuccess("$transport_name added successfully.");
} else {
flash()->addError("$transport_name was not added. Check the log for details.");
}
}
}
// remove get variables otherwise things will get double added
echo '<script>window.history.replaceState(null, null, window.location.pathname);</script>';
}
unset($request);
// print alert transports
require_once 'includes/html/print-alert-transports.php';
} else {
include 'includes/html/error-no-perm.inc.php';
}