-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.php
executable file
·85 lines (71 loc) · 2.83 KB
/
bootstrap.php
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
<?php
use App\Services\Hook;
use Blessing\Filter;
use Blessing\Rejection;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use LittleSkin\PremiumVerification\Models\Premium;
return function (Dispatcher $events, Filter $filter, Request $request) {
$config = [
'client_id' => env('MICROSOFT_CLIENT_ID'),
'client_secret' => env('MICROSOFT_CLIENT_SECRET'),
'tenant' => 'consumers',
];
config(['services.microsoftoidc' => $config + [
'redirect' => env('MICROSOFT_LOGIN_REDIRECT_URI'),
]]);
config(['services.premium' => $config + [
'redirect' => env('MICROSOFT_PREMIUM_REDIRECT_URI'),
]]);
if ($request->is('auth/login') || $request->is('auth/register')) {
$filter->add('oauth_providers', function (Collection $providers) {
$providers->put('microsoftoidc', [
'icon' => 'microsoft',
'displayName' => 'Microsoft',
]);
return $providers;
});
}
$events->listen(
'SocialiteProviders\Manager\SocialiteWasCalled',
'LittleSkin\PremiumVerification\Providers\ExtendSocialite@handle'
);
$events->listen(
Illuminate\Auth\Events\Authenticated::class,
'LittleSkin\PremiumVerification\Listeners\OnAuthenticated@handle'
);
$events->listen(
'player.delete.attempt',
'LittleSkin\PremiumVerification\Listeners\OnPlayerDeleteAttempt@handle'
);
$events->listen(
'user.deleting',
'LittleSkin\PremiumVerification\Listeners\OnUserDeleting@handle'
);
$filter->add('user_badges', function ($badges, $user) {
if(Premium::where('uid', $user->uid)->first()) {
$badges[] = ['text' => trans('LittleSkin\PremiumVerification::general.pro'), 'color' => 'purple'];
}
return $badges;
});
Hook::addRoute(function () {
Route::prefix('user/premium')
->middleware(['web', 'auth'])
->namespace('LittleSkin\PremiumVerification\Controllers')
->group(function () {
Route::get('verify', 'VerificationController@verify');
Route::get('callback', 'VerificationController@callback');
Route::post('update', 'VerificationController@update');
});
Route::prefix('microsoftoidc')
->middleware(['web'])
->namespace('LittleSkin\PremiumVerification\Controllers')
->group(function () {
Route::get('connect', 'MicrosoftOIDCConnectController@redirect');
Route::get('callback', 'MicrosoftOIDCConnectController@callback');
Route::get('disconnect', 'MicrosoftOIDCConnectController@disconnect');
Route::post('inherit', 'MicrosoftOIDCConnectController@inherit');
});
});
};