Repository navigation
Expand file tree
/
Copy pathProvider.php
More file actions
46 lines (35 loc) · 1.7 KB
/
Copy pathProvider.php
File metadata and controls
46 lines (35 loc) · 1.7 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
<?php
/**
* Provides everything needed for the Extension
*/
$config = file_get_contents(__DIR__.'/gp247.json');
$config = json_decode($config, true);
$extensionPath = $config['configGroup'].'/'.$config['configKey'];
$this->loadTranslationsFrom(__DIR__.'/Lang', $extensionPath);
if (gp247_extension_check_active($config['configGroup'], $config['configKey'])) {
$this->loadViewsFrom(__DIR__.'/Views', $extensionPath);
if (file_exists(__DIR__.'/config.php')) {
$this->mergeConfigFrom(__DIR__.'/config.php', $extensionPath);
}
if (file_exists(__DIR__.'/function.php')) {
require_once __DIR__.'/function.php';
}
app('router')->aliasMiddleware('mfa.verify', \App\GP247\Plugins\MFA\Middleware\TwoFactorAuthentication::class);
// // For admin
$admin = (array) config('gp247-config.admin.middleware', []);
if (!in_array('mfa.verify:admin', $admin, true)) {
$admin[] = 'mfa.verify:admin';
config(['gp247-config.admin.middleware' => $admin]);
}
// For front
$customer = (array) config('gp247-config.shop.middleware', []); // customer
if (!in_array('mfa.verify', $customer, true)) {
$customer[] = 'mfa.verify:customer';
config(['gp247-config.shop.middleware' => $customer]);
}
// Ensure runtime Router groups receive middleware even if groups were already registered
app('router')->prependMiddlewareToGroup('admin', 'mfa.verify:admin');
app('router')->prependMiddlewareToGroup('customer', 'mfa.verify:customer');
app('router')->prependMiddlewareToGroup('vendor', 'mfa.verify:vendor');
app('router')->prependMiddlewareToGroup('pmo_partner', 'mfa.verify:pmo_partner');
}