-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
extend.php
55 lines (48 loc) · 2.42 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
use Flarum\Extend;
use Flarum\User\Event\Deleted;
use Flarum\User\Event\LoggedIn;
use Flarum\User\Event\LoggedOut;
use Flarum\User\Event\Registered;
use Flarum\User\Event\Saving;
use Maicol07\SSO\JWTSSOController;
use Maicol07\SSO\Listener\ActivateUser;
use Maicol07\SSO\Listener\AddLogoutRedirect;
use Maicol07\SSO\Listener\LoadSettingsFromDatabase;
use Maicol07\SSO\Listener\ProviderModeListener;
use Maicol07\SSO\Listener\UserUpdated;
use Maicol07\SSO\Middleware\LoginMiddleware;
use Maicol07\SSO\Middleware\LogoutMiddleware;
return [
// Frontend extenders (JS)
(new Extend\Frontend('forum'))->js(__DIR__ . '/js/dist/forum.js'),
(new Extend\Frontend('admin'))->js(__DIR__ . '/js/dist/admin.js'),
// Locales
new Extend\Locales(__DIR__ . '/locale'),
// Events
(new Extend\Event())
->listen(Registered::class, [ActivateUser::class, 'activateUser'])
->listen(LoggedOut::class, [AddLogoutRedirect::class, 'addLogoutRedirect'])
->listen(Saving::class, [UserUpdated::class, 'updateAvatarUrl'])
->listen(Saving::class, [ProviderModeListener::class, 'updateUserInClients'])
->listen(LoggedIn::class, [ProviderModeListener::class, 'loginClients'])
->listen(Deleted::class, [ProviderModeListener::class, 'deleteUserInClients'])
->listen(LoggedOut::class, [ProviderModeListener::class, 'logoutUserInClients'])
->subscribe(LoadSettingsFromDatabase::class),
// Middleware
(new Extend\Middleware('forum'))
->add(LoginMiddleware::class)
->add(LogoutMiddleware::class),
// Routes
(new Extend\Routes('api'))->get('/sso/jwt', 'maicol07.jwt-auth', JWTSSOController::class),
// Settings
(new Extend\Settings())
->serializeToForum('maicol07-sso.signup_url', 'maicol07-sso.signup_url')
->serializeToForum('maicol07-sso.login_url', 'maicol07-sso.login_url')
->serializeToForum('maicol07-sso.logout_url', 'maicol07-sso.logout_url')
->serializeToForum('maicol07-sso.manage_account_url', 'maicol07-sso.manage_account_url')
->serializeToForum('maicol07-sso.manage_account_btn_open_in_new_tab', 'maicol07-sso.manage_account_btn_open_in_new_tab')
->serializeToForum('maicol07-sso.remove_login_btn', 'maicol07-sso.remove_login_btn')
->serializeToForum('maicol07-sso.remove_signup_btn', 'maicol07-sso.remove_signup_btn')
->serializeToForum('maicol07-sso.provider_mode', 'maicol07-sso.provider_mode')
];