| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- $params = require __DIR__ . '/params.php';
- $db = require __DIR__ . '/db.php';
- $config = [
- 'id' => 'basic',
- 'name'=>'Antares-2000',
- 'basePath' => dirname(__DIR__),
- 'bootstrap' => ['log'],
- 'language' => 'ru-RU',
- //'defaultRoute' => 'main/index',
- 'aliases' => [
- '@bower' => '@vendor/bower-asset',
- '@npm' => '@vendor/npm-asset',
- ],
- 'container' => [
- 'definitions' => [
- \yii\widgets\LinkPager::class => \yii\bootstrap4\LinkPager::class,
- ],
- ],
- 'components' => [
- 'request' => [
- // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
- 'cookieValidationKey' => '9F0UJBZKPPoUsJAKuAh9hpvyWdaF1IIb',
- 'parsers' => [
- 'application/json' => 'yii\web\JsonParser',
- ]
- ],
- 'cache' => [
- 'class' => 'yii\caching\FileCache',
- ],
- 'user' => [
- 'class' => 'app\components\User',
- 'loginUrl' => ['login'],
- //'returnUrl' => ['home'],
- 'identityClass' => 'app\models\user\User',
- ],
- 'errorHandler' => [
- 'errorAction' => 'site/error',
- ],
- 'mailer' => [
- 'class' => 'yii\swiftmailer\Mailer',
- // send all mails to a file by default. You have to set
- // 'useFileTransport' to false and configure a transport
- // for the mailer to send real emails.
- //'useFileTransport' => false,
- 'transport' => [
- 'class' => 'Swift_SmtpTransport',
- 'host' => $_ENV['SMTP_HOST'],
- 'username' => $_ENV['SMTP_LOGIN'],
- 'password' => $_ENV['SMTP_PASS'],
- 'port' => $_ENV['SMTP_PORT'],
- 'encryption' => $_ENV['SMTP_ENC'],
- ],
- ],
- 'log' => [
- 'traceLevel' => YII_DEBUG ? 3 : 0,
- 'targets' => [
- [
- 'class' => 'yii\log\FileTarget',
- 'levels' => ['error', 'warning'],
- ],
- ],
- ],
- 'db' => $db,
- 'urlManager' => [
- 'enablePrettyUrl' => true,
- 'enableStrictParsing' => true,
- 'showScriptName' => false,
- 'rules' => [
- [
- 'class' => 'yii\rest\UrlRule',
- 'controller' => ['api/user'],
- 'extraPatterns' => [
- 'POST add' => 'bulk-add',
- ],
- ],
- '/' => 'site/index',
- 'pricing/<action:[\w\-]+>' => 'pricing/<action>',
- 'profile/<action:[\w\-]+>' => 'profile/<action>',
- 'pay/<action:[\w\-]+>' => 'pay/<action>',
- 'history/<action:[\w\-]+>' => 'history/<action>',
- //'user/admin/<action:\w+>' => 'user/admin/<action>',
- 'user/<controller:[\w\-]+>/<action:[\w\-]+>' => 'user/<controller>/<action>',
- //'login' => 'user/security/login',
- '<alias:logout|login>' => 'user/security/<alias>',
- //'api/<action:\w+>' => 'api/<action>',
- //'api/<action:[\w\-]+>/<id:\d+>' => 'api/<action>'
- ],
- ],
- 'i18n' => [
- 'translations' => [
- 'app' => [
- 'class' => 'yii\i18n\PhpMessageSource',
- 'basePath' => '@app/messages',
- 'sourceLanguage' => 'en',
- 'fileMap' => [
- 'app' => 'app.php',
- ],
- ],
- 'user' => [
- 'class' => 'yii\i18n\PhpMessageSource',
- 'basePath' => '@app/messages',
- 'on missingTranslation' => ['app\components\TranslationEventHandler', 'handleMissingTranslation']
- ],
- ],
- ],
- 'view' => [
- 'theme' => [
- 'pathMap' => [
- '@dektrium/user/views' => '@app/views/user'
- ],
- ],
- ],
- 'assetManager' => [
- 'bundles' => [
- 'yii\bootstrap\BootstrapPluginAsset' => [
- 'js'=>[]
- ],
- 'yii\bootstrap\BootstrapAsset' => [
- 'css' => [],
- ],
- ],
- ],
- ],
- 'modules' => [
- 'user' => [
- 'class' => 'dektrium\user\Module',
- 'enableRegistration' => false,
- 'enablePasswordRecovery' => true,
- 'enableConfirmation' => false,
- //'adminPermission' => 'admin',
- //'admins' => ['ptenchik0'],
- 'rememberFor' => 86400,
- //'debug' => true,
- 'controllerMap' => [
- 'settings' => 'app\controllers\ProfileController'
- ],
- 'modelMap' => [
- //'RecoveryForm' => 'app\models\security\RecoveryForm',
- //'RegistrationForm' => 'app\models\security\RegistrationForm',
- 'User' => 'app\models\user\User',
- //'UserSearch' => 'app\models\search\Users',
- 'LoginForm' => 'app\models\user\LoginForm',
- //'Profile' => 'app\models\user\Profile',
- //'SettingsForm' => 'app\models\user\SettingsForm',
- ],
- ],
- 'api' => [
- 'class' => 'app\modules\api\Module',
- ],
- ],
- 'params' => $params,
- 'on beforeAction' => function ($event) {
- if (Yii::$app->user->isGuest) :
- Yii::$app->layout = 'guest';
- else:
- $email = substr(Yii::$app->user->identity->email, strripos(Yii::$app->user->identity->email, '@') + 1 );
- if('example.com' === $email){
- $pass_link = \yii\bootstrap4\Html::a('Змінити', \yii\helpers\Url::to(['profile/account']), ['class'=>'text-uppercase']);
- Yii::$app->session->setFlash('warning', 'Для можливості відновлення паролю, будь-ласка, змініть свій <strong>Email</strong>. ' . $pass_link);
- }
- if(Yii::$app->user->identity->created_at == Yii::$app->user->identity->updated_at){
- $pass_link = \yii\bootstrap4\Html::a('Змінити', \yii\helpers\Url::to(['profile/account']), ['class'=>'text-white text-uppercase']);
- Yii::$app->session->setFlash('danger', '<strong>Ваш пароль є тимчасовым</strong>. З розумінь безпеки, будь-ласка, змініть свій пароль. ' . $pass_link);
- }
- endif;
- },
- 'as globalAccess' => [
- 'class' => app\components\GlobalAccessBehavior::class,
- 'rules' => [
- [
- 'actions' => ['error'],
- 'allow' => true,
- 'roles' => ["?","@"],
- ],
- [
- 'actions' => ['login', 'request'],
- 'allow' => true,
- 'roles' => ['?'],
- ],
- [
- 'actions' => ['logout'],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- /*
- [
- 'controllers' => ['api/user'],
- 'allow' => true,
- 'roles' => ['?'],
- ],*/
- [
- 'controllers' => ['user/admin'],
- 'allow' => true,
- 'roles' => ['admin'],
- ],
- [
- 'controllers' => ['user/admin', 'user/settings', 'user/profile'],
- 'allow' => false,
- ],
- [
- 'allow' => true,
- 'roles' => ['client', 'admin'],
- ],
- // [
- // 'controllers' => ['sign-in'],
- // 'allow' => true,
- // 'roles' => ['?'],
- // 'actions' => ['login'],
- // ],
- // [
- // 'controllers' => ['sign-in'],
- // 'allow' => true,
- // 'roles' => ['@'],
- // 'actions' => ['logout'],
- // ],
- // [
- // 'controllers' => ['site'],
- // 'allow' => true,
- // 'roles' => ['?', '@'],
- // 'actions' => ['error'],
- // ],
- // [
- // 'controllers' => ['debug/default'],
- // 'allow' => true,
- // 'roles' => ['?'],
- // ],
- // [
- // 'controllers' => ['user'],
- // 'allow' => true,
- // 'roles' => ['administrator'],
- // ],
- // [
- // 'controllers' => ['user'],
- // 'allow' => false,
- // ],
- // [
- // 'allow' => true,
- // 'roles' => ['manager', 'administrator'],
- // ],
- ],
- ],
- ];
- if (YII_ENV_DEV) {
- // configuration adjustments for 'dev' environment
- $config['bootstrap'][] = 'debug';
- $config['modules']['debug'] = [
- 'class' => 'yii\debug\Module',
- // uncomment the following to add your IP if you are not connecting from localhost.
- //'allowedIPs' => ['127.0.0.1', '::1'],
- ];
- $config['bootstrap'][] = 'gii';
- $config['modules']['gii'] = [
- 'class' => 'yii\gii\Module',
- // uncomment the following to add your IP if you are not connecting from localhost.
- //'allowedIPs' => ['127.0.0.1', '::1'],
- ];
- }
- return $config;
|