-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextend.php
55 lines (43 loc) · 2.12 KB
/
extend.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
<?php
namespace Nearata\TwoFactor;
use Flarum\Api\Serializer\BasicUserSerializer;
use Flarum\Extend;
use Flarum\User\User;
use Nearata\TwoFactor\Api\Controller\AppBackupsController;
use Nearata\TwoFactor\Api\Controller\AppQRCodeController;
use Nearata\TwoFactor\Api\Controller\AppUpdateController;
use Nearata\TwoFactor\Api\Controller\TwoFactorController;
use Nearata\TwoFactor\Api\Serializer\BasicUserSerializerAttributes;
use Nearata\TwoFactor\Forum\Controller\LogInController;
use Nearata\TwoFactor\Forum\Controller\TwoFactorLogInController;
use Nearata\TwoFactor\Forum\ForumServiceProvider;
return [
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Routes('api'))
->get('/nearata/twofactor', 'nearata-twofactor.index', TwoFactorController::class)
->patch('/nearata/twofactor/app', 'nearata-twofactor.app.update', AppUpdateController::class)
->get('/nearata/twofactor/app/qrcode', 'nearata-twofactor.app.qrcode', AppQRCodeController::class)
->get('/nearata/twofactor/app/backups', 'nearata-twofactor.app.backups', AppBackupsController::class),
(new Extend\Routes('forum'))
->remove('login')
->post('/login', 'login', LogInController::class)
->post('/nearata/twofactor/login', 'nearata-twofactor.login', TwoFactorLogInController::class),
(new Extend\Settings())
->default('nearata-twofactor.admin.generate_backups', false)
->serializeToForum('canGenerateBackups', 'nearata-twofactor.admin.generate_backups', 'boolval'),
(new Extend\ApiSerializer(BasicUserSerializer::class))
->attributes(BasicUserSerializerAttributes::class),
(new Extend\Model(User::class))
->cast('twofa_app_secret', 'string')
->cast('twofa_app_active', 'boolean')
->cast('twofa_app_codes', 'array'),
(new Extend\Csrf)
->exemptRoute('nearata-twofactor.login'),
(new Extend\ServiceProvider)
->register(ForumServiceProvider::class)
];