-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
95 lines (83 loc) · 3.15 KB
/
Copy pathbootstrap.php
File metadata and controls
95 lines (83 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
use App\Services\Hook;
use Blessing\Filter;
use Illuminate\Support\Facades\Route;
return function () {
Hook::addRoute(function () {
// OAuth authorization records
Route::namespace('OAuthRecord\Controllers')
->prefix('user/oauth-record')
->middleware(['web', 'authorize', 'verified'])
->group(function () {
Route::get('', 'OAuthRecordController@index');
Route::post('revoke/{tokenId}', 'OAuthRecordController@revoke');
Route::post('revoke-client/{clientId}', 'OAuthRecordController@revokeClient');
});
// OAuth App Hall
Route::namespace('OAuthRecord\Controllers')
->prefix('oauth-apps')
->middleware(['web', 'authorize'])
->group(function () {
Route::get('', 'AppHallController@index');
Route::get('favicon', 'AppHallController@favicon');
});
// Developer-facing hall visibility management (own clients only)
Route::namespace('OAuthRecord\Controllers')
->prefix('user/oauth-apps')
->middleware(['web', 'authorize', 'verified'])
->group(function () {
Route::get('manage', 'AppHallController@manage');
Route::post('manage/visibility', 'AppHallController@toggleVisibility');
});
// Admin cleanup route
Route::namespace('OAuthRecord\Controllers')
->prefix('admin/oauth-record')
->middleware(['web', 'auth', 'role:admin'])
->group(function () {
Route::post('cleanup', 'ConfigController@cleanup');
Route::post('cleanup-redundant', 'ConfigController@cleanupRedundant');
});
});
if (option('oauth_record_enable_app_hall', true)) {
Hook::addMenuItem('explore', 0, [
'title' => 'OAuthRecord::oauth-record.hall-title',
'link' => 'oauth-apps',
'icon' => 'fa-th-large',
]);
}
resolve(Filter::class)->add('side_menu', function ($menu, $type) {
if ($type !== 'user') {
return $menu;
}
$children = [];
if (option('oauth_record_enable_auth_record', true)) {
$children[] = [
'title' => 'OAuthRecord::oauth-record.title',
'link' => 'user/oauth-record',
'icon' => 'fa-key',
];
}
if (option('oauth_record_enable_app_hall', true)) {
$children[] = [
'title' => 'OAuthRecord::oauth-record.manage-title',
'link' => 'user/oauth-apps/manage',
'icon' => 'fa-cog',
];
}
if (empty($children)) {
return $menu;
}
$mounted = false;
foreach ($menu as &$item) {
if (($item['title'] ?? '') === 'general.developer') {
$item['children'] = array_merge($item['children'] ?? [], $children);
$mounted = true;
break;
}
}
if (!$mounted) {
array_push($menu, ...$children);
}
return $menu;
});
};