Skip to content
Snippets Groups Projects
Commit 088fbd21 authored by Tibo's avatar Tibo
Browse files

Add organization public dashboard

parent 8f1f8571
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,7 @@ class RegisterController extends Controller
{
$organization = new Organization();
$organization->name = $data["name"];
$organization->dashboard_token = \str_random(20);
$organization->save();
$user = User::create([
......
......@@ -24,7 +24,7 @@ class OrganizationController extends Controller
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|regex:/^[a-zA-Z0-9\s-\.]+$/|max:255'
'name' => 'required|string|regex:/^[a-zA-Z0-9\s\-\.]+$/|max:255'
]);
}
......@@ -63,6 +63,7 @@ class OrganizationController extends Controller
$organization = new Organization();
$organization->name = $request->name;
$organization->dashboard_token = \str_random(20);
Auth::user()->organizations()->save($organization);
return redirect(action('OrganizationController@index'));
......
......@@ -107,7 +107,8 @@ class Ifconfig extends AbstractSensor {
}
/**
* Parse the result of the ifconfig command.
* Parse the result of the ifconfig command, skipping every virtual
* interfaces (docker, br, lo)
* @param type $string
* @return \App\Sensor\NetworkInterface[]
*/
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class OrganizationsAddDashboardToken extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('organizations', function (Blueprint $table) {
$table->string("dashboard_token")->default("im6muV8NZ9wWCmnhFAIr");
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('organizations', function (Blueprint $table) {
//
});
}
}
......@@ -6,10 +6,21 @@
<div class="col-md-3">
<div class="card">
<div class="card-body">
<a class="btn btn-primary btn-sm"
href="{{ action("OrganizationController@dashboard", ["organization" => $organization]) }}">
Dashboard
</a>
<p>
<a class="btn btn-primary btn-sm"
href="{{ action("OrganizationController@dashboard", ["organization" => $organization]) }}">
Dashboard
</a>
</p>
<p>
<a class="btn btn-primary btn-sm"
href="{{ route("organization.public.dashboard", [
"organization" => $organization,
"token" => $organization->dashboard_token]) }}">
Public dashboard
</a>
</p>
</div>
</div>
......
......@@ -26,7 +26,15 @@ Route::get('app/dashboard', function() {
})->name('dashboard');
Route::get('app/organizations/{organization}/dashboard', 'OrganizationController@dashboard');
Route::get('app/organizations/{organization}/dashboard/{token}',
function(\App\Organization $organization, string $token) {
if ($organization->dashboard_token != $token) {
abort(403);
}
return view("organization.dashboard", array("organization" => $organization));
})->name("organization.public.dashboard");
Route::resource('app/organizations', 'OrganizationController');
Route::resource("app/organizations.user", "OrganizationUserController");
Route::resource('app/servers', 'ServerController');
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment