Commit c9a35ea8 authored by Timothée Jaussoin's avatar Timothée Jaussoin

Add devices management panel

parent 273fd1e1
Pipeline #15436 passed with stages
in 1 minute and 13 seconds
<?php
namespace App\Http\Controllers\Account;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Libraries\FlexisipConnector;
class DeviceController extends Controller
{
public function index(Request $request)
{
$connector = new FlexisipConnector;
return view('account.devices.index',
['devices' => $connector->getDevices($request->user()->identifier)
->keyBy('uuid')
]);
}
public function delete(Request $request, string $uuid)
{
$connector = new FlexisipConnector;
return view('account.devices.delete',
['device' => $connector->getDevices($request->user()->identifier)
->keyBy('uuid')
->where('uuid', $uuid)
]);
}
public function destroy(string $uuid)
{
$connector = new FlexisipConnector;
$connector->deleteDevice($request->user()->identifier, $uuid);
return redirect()->route('account.device.index');
}
}
@extends('layouts.account')
@section('breadcrumb')
<li class="breadcrumb-item" aria-current="page">
<a href="{{ route('account.device.index') }}">Devices</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Delete</li>
@endsection
@section('content')
<h2>Device deletion</h2>
<p>Are you sure you want to delete the following device?</p>
<p>
<b>User Agent:</b> {{ $device->user_agent }}<br />
<b>Expires At:</b> {{ $device->expires_at }}</p>
</p>
{!! Form::open(['route' => 'account.device.destroy', 'method' => 'delete']) !!}
{!! Form::hidden('uuid', $device->uuid) !!}
{!! Form::submit('Delete', ['class' => 'btn btn-danger float-right']) !!}
{!! Form::close() !!}
@endsection
\ No newline at end of file
@extends('layouts.account')
@section('breadcrumb')
<li class="breadcrumb-item active" aria-current="page">Devices</li>
@endsection
@section('content')
<table class="table table-responsive-md">
<thead>
<tr>
<th scope="col">User Agent</th>
<th scope="col">Expires At</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@foreach ($devices as $device)
<tr>
<td>{{ $device->user_agent }}</td>
<td>{{ $account->expires_at }}</td>
<td>
<a type="button"
class="btn btn-danger"
href="{{ route('account.device.delete', $device->uuid) }}">
Delete
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@endsection
\ No newline at end of file
......@@ -13,6 +13,12 @@
<p class="mb-1">No email yet</p>
@endif
</a>
<a href="{{ route('account.device.index') }}" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Manage my devices</h5>
</div>
<p class="mb-1">See and delete the devices linked to your account</p>
</a>
<a href="{{ route('account.password') }}" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Change my password</h5>
......
......@@ -45,6 +45,10 @@ Route::group(['middleware' => 'auth'], function () {
Route::post('email', 'AccountEmailController@update')->name('account.email.update');
Route::get('password', 'AccountPasswordController@show')->name('account.password');
Route::post('password', 'AccountPasswordController@update')->name('account.password.update');
Route::get('devices', 'Account\DeviceController@index')->name('account.device.index');
Route::get('devices/delete/{id}', 'Account\DeviceController@delete')->name('account.device.delete');
Route::delete('devices/{id}', 'Account\DeviceController@destroy')->name('account.device.destroy');
});
Route::group(['middleware' => 'auth.admin'], function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment