forked from mapasculturais/plugin-MultipleLocalAuth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
61 lines (49 loc) · 2.66 KB
/
Plugin.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
<?php
namespace SaaSMultipleLocalAuth;
use MapasCulturais\App;
use MapasCulturais\i;
include('Facebook/FacebookStrategy.php');
include('Google/GoogleStrategy.php');
include('LinkedIn/LinkedInStrategy.php');
include('LoginCidadao/LoginCidadaoStrategy.php');
include('GovBr/GovBrStrategy.php');
class Plugin extends \MapasCulturais\Plugin {
public function _init() {
$app = App::i();
// register translation text domain
i::load_textdomain( 'multipleLocal', __DIR__ . "/translations" );
// Load JS & CSS
$app->hook('GET(<<auth|panel>>.<<*>>):before', function() use ($app) {
$app->view->enqueueStyle('app-v2', 'multipleLocal-v2', 'css/plugin-MultiplLocalAuth.css');
});
$app->hook('GET(auth.<<index|register>>)', function() use($app) {
if (env('GOOGLE_RECAPTCHA_SITEKEY', false)) {
$app->view->enqueueScript('app-v2', 'multipleLocal-v2', 'https://www.google.com/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit');
}
});
$app->hook('template(panel.<<my-account|user-detail>>.user-mail):end ', function() {
/** @var \MapasCulturais\Theme $this */
$this->part('password/change-password');
});
$app->hook('entity(User).permissionsList,doctrine.emum(permission_action).values', function (&$permissions) {
$permissions[] = 'changePassword';
});
$app->hook('module(UserManagement).permissionsLabels', function(&$labels) {
$labels['changePassword'] = i::__('modificar senha');
});
if (php_sapi_name() == "cli") {
if (!isset($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = 'localhost';
}
}
}
public function register() {
$this->registerUserMetadata(Provider::$passMetaName, ['label' => i::__('Senha')]);
$this->registerUserMetadata(Provider::$recoverTokenMetadata, ['label' => i::__('Token para recuperação de senha')]);
$this->registerUserMetadata(Provider::$recoverTokenTimeMetadata, ['label' => i::__('Timestamp do token para recuperação de senha')]);
$this->registerUserMetadata(Provider::$accountIsActiveMetadata, ['label' => i::__('Conta ativa?')]);
$this->registerUserMetadata(Provider::$tokenVerifyAccountMetadata, ['label' => i::__('Token de verificação')]);
$this->registerUserMetadata(Provider::$loginAttempMetadata, ['label' => i::__('Número de tentativas de login')]);
$this->registerUserMetadata(Provider::$timeBlockedloginAttempMetadata, ['label' => i::__('Tempo de bloqueio por excesso de tentativas')]);
}
}