|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
|
6
|
|
|
|
|
7
|
|
|
class TwoFactorCrudController extends CrudController |
|
8
|
|
|
{ |
|
9
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
|
|
|
|
|
|
10
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Prepare the admin interface by setting the associated |
|
14
|
|
|
* model, setting the route, and adding custom columns/fields. |
|
15
|
|
|
* |
|
16
|
|
|
* @return void |
|
17
|
|
|
*/ |
|
18
|
|
|
public function setup() : void |
|
19
|
|
|
{ |
|
20
|
|
|
$this->crud->setModel('App\Models\User'); |
|
21
|
|
|
$this->crud->setRoute('admin/2fa'); |
|
22
|
|
|
$this->crud->setEntityNameStrings('Manage 2FA', 'Manage 2FA'); |
|
23
|
|
|
// Only show current user. |
|
24
|
|
|
if (\Auth::user()->hasRole('admin')) { |
|
25
|
|
|
$this->crud->addClause('where', 'id', '=', \Auth::user()->id); |
|
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function setupListOperation() |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$this->crud->removeButton('update'); |
|
32
|
|
|
|
|
33
|
|
|
$this->crud->addColumn([ |
|
34
|
|
|
'name' => 'id', |
|
35
|
|
|
'type' => 'text', |
|
36
|
|
|
'label' => 'ID', |
|
37
|
|
|
'orderable' => false |
|
38
|
|
|
]); |
|
39
|
|
|
|
|
40
|
|
|
$this->crud->addColumn([ |
|
41
|
|
|
'name' => 'full_name', |
|
42
|
|
|
'type' => 'text', |
|
43
|
|
|
'label' => 'Name', |
|
44
|
|
|
'orderable' => false |
|
45
|
|
|
]); |
|
46
|
|
|
|
|
47
|
|
|
$this->crud->addColumn([ |
|
48
|
|
|
'name' => 'google2fa_secret', |
|
49
|
|
|
'type' => 'check', |
|
50
|
|
|
'label' => '2FA Enabled', |
|
51
|
|
|
'orderable' => false |
|
52
|
|
|
]); |
|
53
|
|
|
|
|
54
|
|
|
$this->crud->addColumn([ |
|
55
|
|
|
'name' => 'recovery_codes', |
|
56
|
|
|
'type' => 'array_count', |
|
57
|
|
|
'label' => 'Recovery Codes', |
|
58
|
|
|
'orderable' => false, |
|
59
|
|
|
]); |
|
60
|
|
|
|
|
61
|
|
|
// Add the custom blade buttons (resources/views/vendor/backpack/crud/buttons). |
|
62
|
|
|
$this->crud->addButtonFromView('line', 'recovery_codes', 'recovery_codes', 'beginning'); |
|
63
|
|
|
$this->crud->addButtonFromView('line', 'activate_2fa', 'activate_2fa', 'end'); |
|
64
|
|
|
$this->crud->addButtonFromView('line', 'deactivate_2fa', 'deactivate_2fa', 'end'); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|