'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/' => 'pricing/', 'profile/' => 'profile/', 'pay/' => 'pay/', 'history/' => 'history/', //'user/admin/' => 'user/admin/', 'user//' => 'user//', //'login' => 'user/security/login', '' => 'user/security/', //'api/' => 'api/', //'api//' => 'api/' ], ], '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\user\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', 'Для можливості відновлення паролю, будь-ласка, змініть свій Email. ' . $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', 'Ваш пароль є тимчасовым. З розумінь безпеки, будь-ласка, змініть свій пароль. ' . $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;