Example application configuration: php 'components' => [ 'authClientCollection' => [ 'class' => 'yii\authclient\Collection', 'clients' => [ 'google' => [ 'class' => 'yii\authclient\clients\Google', 'clientId' => 'google_client_id', 'clientSecret' => 'google_client_secret', ], 'facebook' => [ 'class' => 'yii\authclient\clients\Facebook', 'clientId' => 'facebook_client_id', 'clientSecret' => 'facebook_client_secret', ], ], ] ... ]
Since: 2.0
Author: Paul Klimov (klimov.paul@gmail.com)
Inheritance: extends yii\base\Component
Example #1
2
 /**
  * Bootstraps the module for the web application.
  *
  * @param \yii\web\Application $app application instance.
  */
 protected function bootstrapWebApplication($app)
 {
     /** @var Module $module */
     $module = $app->getModule(Module::MODULE_ID);
     // prepend the URL rules to the URL manager
     $app->getUrlManager()->addRules([new GroupUrlRule($module->urlConfig)], false);
     // Configure the web user component
     $app->set('user', ArrayHelper::merge(['class' => $module->getClassName(Module::CLASS_WEB_USER), 'identityClass' => $module->getClassName(Module::CLASS_ACCOUNT), 'loginUrl' => $module->createRoute(Module::URL_ROUTE_LOGIN), 'enableAutoLogin' => true], $module->userConfig));
     // configure client authentication if necessary
     if ($module->enableClientAuth && !$app->has('authClientCollection')) {
         $app->set('authClientCollection', ArrayHelper::merge(['class' => Collection::className(), 'clients' => ['google' => ['class' => GoogleOpenId::className()]]], $module->clientAuthConfig));
     }
 }
 /**
  * @depends testSetGet
  */
 public function testHasProvider()
 {
     $collection = new Collection();
     $clientName = 'testClientName';
     $clients = [$clientName => ['class' => 'TestClient1']];
     $collection->setClients($clients);
     $this->assertTrue($collection->hasClient($clientName), 'Existing client check fails!');
     $this->assertFalse($collection->hasClient('unExistingClientName'), 'Not existing client check fails!');
 }
Example #3
0
 /** @inheritdoc */
 public function bootstrap($app)
 {
     /** @var $module Module */
     if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
         $this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
         foreach ($this->_modelMap as $name => $definition) {
             $class = "dektrium\\user\\models\\" . $name;
             \Yii::$container->set($class, $definition);
             $modelName = is_array($definition) ? $definition['class'] : $definition;
             $module->modelMap[$name] = $modelName;
             if (in_array($name, ['User', 'Profile', 'Token', 'Account'])) {
                 \Yii::$container->set($name . 'Query', function () use($modelName) {
                     return $modelName::find();
                 });
             }
         }
         \Yii::$container->setSingleton(Finder::className(), ['userQuery' => \Yii::$container->get('UserQuery'), 'profileQuery' => \Yii::$container->get('ProfileQuery'), 'tokenQuery' => \Yii::$container->get('TokenQuery'), 'accountQuery' => \Yii::$container->get('AccountQuery')]);
         if ($app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'dektrium\\user\\commands';
         } else {
             \Yii::$container->set('yii\\web\\User', ['enableAutoLogin' => true, 'loginUrl' => ['/user/security/login'], 'identityClass' => $module->modelMap['User']]);
             $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules];
             if ($module->urlPrefix != 'user') {
                 $configUrlRule['routePrefix'] = 'user';
             }
             $app->get('urlManager')->rules[] = new GroupUrlRule($configUrlRule);
             if (!$app->has('authClientCollection')) {
                 $app->set('authClientCollection', ['class' => Collection::className()]);
             }
         }
         $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         $defaults = ['welcomeSubject' => \Yii::t('user', 'Welcome to {0}', \Yii::$app->name), 'confirmationSubject' => \Yii::t('user', 'Confirm account on {0}', \Yii::$app->name), 'reconfirmationSubject' => \Yii::t('user', 'Confirm email change on {0}', \Yii::$app->name), 'recoverySubject' => \Yii::t('user', 'Complete password reset on {0}', \Yii::$app->name)];
         \Yii::$container->set('dektrium\\user\\Mailer', array_merge($defaults, $module->mailer));
     }
 }
 /**
  * Gets first client by default.
  */
 public function getClient($id = null)
 {
     if ($id === null) {
         list($id, $dummy) = each($this->getClients());
     }
     return parent::getClient($id);
 }
Example #5
0
 /** @inheritdoc */
 public function bootstrap($app)
 {
     /** @var Module $module */
     /** @var \yii\db\ActiveRecord $modelName */
     if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
         Yii::$container->setSingleton(UserFinder::className(), ['userQuery' => \jarrus90\User\models\User::find(), 'profileQuery' => \jarrus90\User\models\Profile::find(), 'tokenQuery' => \jarrus90\User\models\Token::find(), 'accountQuery' => \jarrus90\User\models\Account::find()]);
         if (!isset($app->get('i18n')->translations['rbac'])) {
             $app->get('i18n')->translations['rbac'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US'];
         }
         if (!isset($app->get('i18n')->translations['user'])) {
             $app->get('i18n')->translations['user'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US'];
         }
         if (!$app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'jarrus90\\User\\Controllers';
             if (!Yii::$container->has('yii\\web\\User')) {
                 Yii::$container->set('yii\\web\\User', ['enableAutoLogin' => true, 'loginUrl' => ['/user/security/login'], 'identityClass' => \jarrus90\User\models\User::className()]);
             }
             $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules];
             if ($module->urlPrefix != 'user') {
                 $configUrlRule['routePrefix'] = 'user';
             }
             $configUrlRule['class'] = 'yii\\web\\GroupUrlRule';
             $rule = Yii::createObject($configUrlRule);
             $app->urlManager->addRules([$rule], false);
             if (!$app->has('authClientCollection')) {
                 $app->set('authClientCollection', ['class' => Collection::className()]);
             }
             $app->params['admin']['menu']['user'] = function () use($module) {
                 return $module->getAdminMenu();
             };
             $app->params['admin']['menu']['logout'] = ['label' => Yii::t('user', 'Logout'), 'icon' => '<i class="fa fa-sign-out"></i>', 'url' => '/user/security/logout'];
         } else {
             if (empty($app->controllerMap['migrate'])) {
                 $app->controllerMap['migrate']['class'] = 'yii\\console\\controllers\\MigrateController';
             }
             $app->controllerMap['migrate']['migrationNamespaces'][] = 'jarrus90\\User\\migrations';
         }
         if (!$app->authManager instanceof DbManager) {
             $app->set('authManager', ['class' => DbManager::className(), 'cache' => $app->cache]);
         }
         Yii::$container->set('jarrus90\\User\\Mailer', $module->mailer);
     }
 }
Example #6
0
 /** @inheritdoc */
 public function bootstrap($app)
 {
     /** @var Module $module */
     /** @var \yii\db\ActiveRecord $modelName */
     if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
         $this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
         foreach ($this->_modelMap as $name => $definition) {
             $class = "dektrium\\user\\models\\" . $name;
             Yii::$container->set($class, $definition);
             $modelName = is_array($definition) ? $definition['class'] : $definition;
             $module->modelMap[$name] = $modelName;
             if (in_array($name, ['User', 'Profile', 'Token', 'Account'])) {
                 Yii::$container->set($name . 'Query', function () use($modelName) {
                     return $modelName::find();
                 });
             }
         }
         Yii::$container->setSingleton(Finder::className(), ['userQuery' => Yii::$container->get('UserQuery'), 'profileQuery' => Yii::$container->get('ProfileQuery'), 'tokenQuery' => Yii::$container->get('TokenQuery'), 'accountQuery' => Yii::$container->get('AccountQuery')]);
         if ($app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'dektrium\\user\\commands';
         } else {
             Yii::$container->set('yii\\web\\User', ['enableAutoLogin' => true, 'loginUrl' => ['/user/security/login'], 'identityClass' => $module->modelMap['User']]);
             $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules];
             if ($module->urlPrefix != 'user') {
                 $configUrlRule['routePrefix'] = 'user';
             }
             $configUrlRule['class'] = 'yii\\web\\GroupUrlRule';
             $rule = Yii::createObject($configUrlRule);
             $app->urlManager->addRules([$rule], false);
             if (!$app->has('authClientCollection')) {
                 $app->set('authClientCollection', ['class' => Collection::className()]);
             }
         }
         if (!isset($app->get('i18n')->translations['user*'])) {
             $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         }
         Yii::$container->set('dektrium\\user\\Mailer', $module->mailer);
     }
 }
<?php

return ['language' => 'es', 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'i18n' => ['translations' => ['*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@common/messages']]], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['google' => ['class' => 'dektrium\\user\\clients\\Google', 'clientId' => '259324332868-8qpid5o610psfefsr946uof26v6po813.apps.googleusercontent.com', 'clientSecret' => 'a25NO-XvNaoTtdZ1vVnjbJyR'], 'facebook' => ['class' => 'dektrium\\user\\clients\\Facebook', 'clientId' => '1696107530612303', 'clientSecret' => 'a90d0d7c7f9f2166797871ec854f8bf1'], 'twitter' => ['class' => 'dektrium\\user\\clients\\Twitter', 'consumerKey' => 'i4SBVlp9sHcmFxtCfbD43egjP', 'consumerSecret' => 'iIj5F6wUtjlmj1dDx0xYTBjtZbNiNJF2ArfzKFDF3xsuhKcYaK']]]], 'modules' => ['user' => ['class' => 'dektrium\\user\\Module']]];
Example #8
0
File: main.php Project: no7kpo/denm
<?php

return ['vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'modules' => ['user' => ['class' => 'dektrium\\user\\Module', 'admins' => ['admin'], 'modelMap' => ['LoginForm' => 'common\\models\\LoginForm']]], 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'i18n' => ['translations' => ['*' => ['sourceLanguage' => 'en-US', 'class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@common/messages']]], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['google' => ['class' => 'dektrium\\user\\clients\\Google', 'clientId' => '576934539950-rqhpbetof4bcpviqk0204ba8njv7rdd0.apps.googleusercontent.com', 'clientSecret' => 'UjKbHydPwy0RcLhUuz0prnxH']]]]];
Example #9
0
<?php

use backend\models\Settings;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'app-frontend', 'name' => 'Razzd', 'language' => 'en', 'homeUrl' => '/', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\\controllers', 'modules' => ['user' => ['class' => 'dektrium\\user\\Module', 'enableUnconfirmedLogin' => false, 'confirmWithin' => 21600, 'cost' => 12, 'admins' => ['root'], 'modelMap' => ['RegistrationForm' => 'frontend\\models\\RegistrationForm', 'User' => ['class' => 'frontend\\models\\User', 'on user_create_done' => function ($event) {
    frontend\models\User::assignRazz($event->sender, $event->sender->accounts);
}, 'on user_register_done' => function ($event) {
    frontend\models\User::assignRazz($event->sender, $event->sender->accounts);
}], 'Account' => 'frontend\\models\\Account', 'Profile' => 'frontend\\models\\Profile'], 'controllerMap' => ['profile' => 'frontend\\controllers\\user\\ProfileController', 'registration' => 'frontend\\controllers\\user\\RegistrationController'], 'mailer' => ['viewPath' => '@common/mail']]], 'components' => ['authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['twitter' => ['class' => 'frontend\\controllers\\auth\\Twitter', 'consumerKey' => 'InZnNj4Moo8BlBOWhsWLr4Fdq', 'consumerSecret' => 'ziWfRtmJ3S6PiMiI14a6Ben2XUVti3AIP6iZAQcuRr6b8vhyc3']]], 'request' => ['baseUrl' => ''], 'response' => ['class' => 'yii\\web\\Response', 'on beforeSend' => function ($event) {
    $response = $event->sender;
    if (isset($response->data['data']['status'])) {
        $response->data = ['status' => $response->statusCode, 'statusText' => $response->statusText, 'data' => $response->data['data'], 'message' => isset($response->data['message']) ? $response->data['message'] : ''];
    }
}], 'urlManager' => ['rules' => [['class' => 'yii\\rest\\UrlRule', 'controller' => 'api', 'extraPatterns' => ['GET userinfo' => 'userinfo', 'GET forgotpassword' => 'forgotpassword', 'GET login' => 'login', 'GET registration' => 'registration', 'GET search' => 'search', 'GET razz' => 'razz', 'GET razz-vote' => 'razz-vote', 'GET razz-create' => 'razz-create', 'GET razz-respond' => 'razz-respond']], ['class' => 'frontend\\components\\SiteUrlRule'], 'razz/<id:\\d+>' => 'razz/view', 'razz/new/<type:\\w+>' => 'razz/new', 'razz/new/<type:\\w+>/<id:\\d+>' => 'razz/new', 'razz/related/<id:\\d+>' => 'razz/related', 'razz/respond/<id:\\d+>' => 'razz/respond', 'razz/archive/<id:\\d+>' => 'razz/archive']], 'meta' => ['class' => 'frontend\\components\\Meta'], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'view' => ['theme' => ['pathMap' => ['@dektrium/user/views' => '@frontend/views/user']]], 'errorHandler' => ['errorAction' => 'site/error']], 'params' => $params];
Example #10
0
<?php

return ['urlManager' => require __DIR__ . '/_urlManager.php', 'cache' => ['class' => 'yii\\caching\\FileCache'], 'pair' => ['class' => 'common\\components\\Pairs'], 'h' => ['class' => 'common\\components\\GlobalComponent'], 'view' => ['theme' => ['pathMap' => ['@dektrium/user/views' => '@app/views/user']]], 'upload' => ['class' => 'common\\components\\upload\\UploadWidget'], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['facebook' => ['class' => 'dektrium\\user\\clients\\Facebook', 'clientId' => 'APP_ID', 'clientSecret' => 'APP_SECRET'], 'google' => ['class' => 'dektrium\\user\\clients\\Google', 'clientId' => 'CLIENT_ID', 'clientSecret' => 'CLIENT_SECRET'], 'twitter' => ['class' => 'dektrium\\user\\clients\\Twitter', 'consumerKey' => 'CONSUMER_KEY', 'consumerSecret' => 'CONSUMER_SECRET']]], 'i18n' => ['translations' => ['app*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@common/messages', 'fileMap' => ['app' => 'app.php', 'app/error' => 'error.php']], 'user*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@common/messages/user', 'fileMap' => ['user' => 'user.php', 'user/error' => 'error.php']], ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@kvgrid/messages', 'forceTranslation' => true]]]];
Example #11
0
 /** @inheritdoc */
 public function bootstrap()
 {
     $app = Yii::$app;
     /** @var \yii\db\ActiveRecord $modelName */
     $this->_modelMap = array_merge($this->_modelMap, $this->modelMap);
     foreach ($this->_modelMap as $name => $definition) {
         $class = "yujin1st\\users\\models\\" . $name;
         Yii::$container->set($class, $definition);
         $modelName = is_array($definition) ? $definition['class'] : $definition;
         $this->modelMap[$name] = $modelName;
     }
     if ($app instanceof ConsoleApplication) {
         $this->controllerNamespace = 'yujin1st\\users\\commands';
     } else {
         $this->controllerNamespace = 'yujin1st\\users\\controllers';
         $this->viewPath = '@yujin1st/users/views';
         Yii::$container->set('yii\\web\\User', ['enableAutoLogin' => true, 'loginUrl' => ['/users/security/login'], 'identityClass' => $this->modelMap['User']]);
         if (!$app->has('authClientCollection')) {
             $app->set('authClientCollection', ['class' => Collection::className()]);
         }
     }
     $this->setUrlRules();
     if (!isset($app->get('i18n')->translations['users*'])) {
         $app->get('i18n')->translations['users*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US'];
     }
     $this->on(Module::EVENT_COLLECT_ROLES, function ($event) {
         /** @var $event RbacEvent */
         $event->addClass(Access::className());
     });
     Yii::$container->set('yujin1st\\users\\Mailer', $this->mailer);
 }
Example #12
0
<?php

use hass\base\components\UrlManager;
$params = array_merge(require __DIR__ . '/../params.php', require __DIR__ . '/../params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'hassium-frontend', 'bootstrap' => ['install', 'frontend'], 'modules' => ['frontend' => 'hass\\frontend\\Module', "user" => ['enableUnconfirmedLogin' => true, 'confirmWithin' => 21600, 'cost' => 12, 'as frontend' => 'dektrium\\user\\filters\\FrontendFilter', 'controllerMap' => ['recovery' => 'hass\\frontend\\controllers\\user\\RecoveryController', 'profile' => 'hass\\frontend\\controllers\\user\\ProfileController', 'registration' => 'hass\\frontend\\controllers\\user\\RegistrationController', 'settings' => 'hass\\frontend\\controllers\\user\\SettingsController', "security" => 'hass\\frontend\\controllers\\user\\SecurityController']]], 'components' => ['user' => ['identityClass' => 'hass\\user\\models\\User', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_frontendIdentity', 'httpOnly' => true]], 'session' => ['name' => 'FRONTENDSESSID'], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['qq' => ['class' => 'hass\\authclient\\clients\\QqOAuth', 'clientId' => 'CLIENT_ID', 'clientSecret' => 'CLIENT_SECRET'], 'weibo' => ['class' => 'hass\\authclient\\clients\\WeiboAuth', 'clientId' => 'CLIENT_ID', 'clientSecret' => 'CLIENT_SECRET'], 'weixin' => ['class' => 'hass\\authclient\\clients\\WeixinAuth', 'clientId' => 'CLIENT_ID', 'clientSecret' => 'CLIENT_SECRET'], 'renren' => ['class' => 'hass\\authclient\\clients\\RenrenAuth', 'clientId' => 'CLIENT_ID', 'clientSecret' => 'CLIENT_SECRET'], 'douban' => ['class' => 'hass\\authclient\\clients\\DoubanAuth', 'clientId' => 'CLIENT_ID', 'clientSecret' => 'CLIENT_SECRET']]], "urlManager" => ["class" => '\\hass\\base\\components\\UrlManager', 'enablePrettyUrl' => false, 'showScriptName' => true, 'rules' => [["class" => 'hass\\urlrule\\components\\UrlRule'], '<controller:(post|page|cat|tag)>/<id>' => '<controller>/read', '<controller:(post|page|cat|tag)>s' => '<controller>/list'], 'on ' . UrlManager::EVENT_INIT_RULECACHE => function ($event) {
    if (isset(\Yii::$app->params[APP_INSTALLED_NAME]) == false) {
        return;
    }
    $dbrule = null;
    foreach ($event->urlManager->rules as $rule) {
        if ($rule instanceof \hass\urlrule\components\UrlRule) {
            $dbrule = $rule;
        }
    }
    $ruleCache = [];
    if ($dbrule) {
        // @hass-todo 可以缓存
        $models = \hass\urlrule\models\UrlRule::find()->all();
        foreach ($models as $model) {
            $params = [];
            parse_str($model->defaults, $params);
            $cacheKey = $model->route . '?' . implode('&', array_keys($params));
            $ruleCache[$cacheKey][] = $dbrule;
        }
    }
    $event->ruleCache = array_merge($ruleCache, (array) $event->ruleCache);
}], 'view' => ['class' => '\\hass\\frontend\\components\\View', 'renderers' => ['twig' => ['class' => 'yii\\twig\\ViewRenderer', 'cachePath' => '@runtime/Twig/cache', 'options' => ['auto_reload' => true], 'globals' => ['html' => '\\yii\\helpers\\Html', "string" => '\\yii\\helpers\\StringHelper', "array" => "\\yii\\helpers\\ArrayHelper"], 'extensions' => ['\\hass\\frontend\\twig\\Extension']]]], 'errorHandler' => ['errorAction' => 'site/error'], "search" => ["class" => 'hass\\search\\components\\LikeSearch']], 'params' => $params];
Example #13
0
<?php

$params = (require __DIR__ . '/params.php');
$config = ['id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'modules' => ['user' => ['class' => 'dektrium\\user\\Module'], 'trip' => ['class' => 'app\\modules\\trip\\Module'], 'redactor' => 'yii\\redactor\\RedactorModule'], 'components' => ['request' => ['cookieValidationKey' => 'lkJx8kbZOOgM4owoQEM-ca4jISrDOYp2'], 'cache' => ['class' => 'yii\\caching\\FileCache'], 'user' => ['identityClass' => 'app\\models\\User', 'identityClass' => 'dektrium\\user\\models\\User'], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['facebook' => ['class' => 'dektrium\\user\\clients\\Facebook', 'clientId' => '858833034203200', 'clientSecret' => 'bbef0d20b887fbe722d288917ac39474']]], 'errorHandler' => ['errorAction' => 'site/error'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'useFileTransport' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => require __DIR__ . '/db.php', 'urlManager' => ['class' => 'yii\\web\\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['/' => 'site/index', '/create-event' => 'trip/event/create', '/event/<id:\\d+>' => 'trip/event/view', '/all-event' => 'trip/event/index', '/account' => 'user/settings/account', '/profile' => 'user/settings/profile', '/my-event' => 'trip/event/manage', '/logout' => 'user/logout', '<controller:\\w+>/<id:\\d+>' => '<controller>/view', '<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>' => '<controller>/<action>']]], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module'];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module'];
}
return $config;
 public function actionAuthClient()
 {
     $model = new SettingsForm();
     $model->googleClientId = Yii::$app->config->get(Enum::GOOGLE_CLIENT_ID);
     $model->googleClientSecret = Yii::$app->config->get(Enum::GOOGLE_CLIENT_SECRET);
     $model->facebookClientId = Yii::$app->config->get(Enum::FACEBOOK_CLIENT_ID);
     $model->facebookClientSecret = Yii::$app->config->get(Enum::FACEBOOK_CLIENT_SECRET);
     $model->linkedInClientId = Yii::$app->config->get(Enum::LINKED_IN_CLIENT_ID);
     $model->linkedInClientSecret = Yii::$app->config->get(Enum::LINKED_IN_CLIENT_SECRET);
     $model->githubClientId = Yii::$app->config->get(Enum::GITHUB_CLIENT_ID);
     $model->githubClientSecret = Yii::$app->config->get(Enum::GITHUB_CLIENT_SECRET);
     $model->liveClientId = Yii::$app->config->get(Enum::LIVE_CLIENT_ID);
     $model->liveClientSecret = Yii::$app->config->get(Enum::LIVE_CLIENT_SECRET);
     $model->twitterConsumerKey = Yii::$app->config->get(Enum::TWITTER_CONSUMER_KEY);
     $model->twitterConsumerSecret = Yii::$app->config->get(Enum::TWITTER_CONSUMER_SECRET);
     $config = Configuration::get();
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->config->set(Enum::GOOGLE_CLIENT_ID, $model->googleClientId);
         Yii::$app->config->set(Enum::GOOGLE_CLIENT_SECRET, $model->googleClientSecret);
         Yii::$app->config->set(Enum::FACEBOOK_CLIENT_ID, $model->facebookClientId);
         Yii::$app->config->set(Enum::FACEBOOK_CLIENT_SECRET, $model->facebookClientSecret);
         Yii::$app->config->set(Enum::LINKED_IN_CLIENT_ID, $model->linkedInClientId);
         Yii::$app->config->set(Enum::LINKED_IN_CLIENT_SECRET, $model->linkedInClientSecret);
         Yii::$app->config->set(Enum::GITHUB_CLIENT_ID, $model->githubClientId);
         Yii::$app->config->set(Enum::GITHUB_CLIENT_SECRET, $model->githubClientSecret);
         Yii::$app->config->set(Enum::LIVE_CLIENT_ID, $model->liveClientId);
         Yii::$app->config->set(Enum::LIVE_CLIENT_SECRET, $model->liveClientSecret);
         Yii::$app->config->set(Enum::TWITTER_CONSUMER_KEY, $model->twitterConsumerKey);
         Yii::$app->config->set(Enum::TWITTER_CONSUMER_SECRET, $model->twitterConsumerSecret);
         $config['components']['authClientCollection']['class'] = Collection::className();
         if (!empty($model->googleClientId) && !empty($model->googleClientSecret)) {
             Yii::$app->config->set(Enum::GOOGLE_AUTH, GoogleOAuth::className());
             Yii::$app->config->set(Enum::GOOGLE_CLIENT_ID, $model->googleClientId);
             Yii::$app->config->set(Enum::GOOGLE_CLIENT_SECRET, $model->googleClientSecret);
             $config['components']['authClientCollection']['clients']['google']['class'] = GoogleOAuth::className();
             $config['components']['authClientCollection']['clients']['google']['clientId'] = $model->googleClientId;
             $config['components']['authClientCollection']['clients']['google']['clientSecret'] = $model->googleClientSecret;
         } else {
             Yii::$app->config->set(Enum::GOOGLE_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['google']);
         }
         if (!empty($model->facebookClientId) && !empty($model->facebookClientSecret)) {
             Yii::$app->config->set(Enum::FACEBOOK_AUTH, Facebook::className());
             Yii::$app->config->set(Enum::FACEBOOK_CLIENT_ID, $model->facebookClientId);
             Yii::$app->config->set(Enum::FACEBOOK_CLIENT_SECRET, $model->facebookClientSecret);
             $config['components']['authClientCollection']['clients']['facebook']['class'] = Facebook::className();
             $config['components']['authClientCollection']['clients']['facebook']['clientId'] = $model->facebookClientId;
             $config['components']['authClientCollection']['clients']['facebook']['clientSecret'] = $model->facebookClientSecret;
         } else {
             Yii::$app->config->set(Enum::FACEBOOK_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['facebook']);
         }
         if (!empty($model->linkedInClientId) && !empty($model->linkedInClientSecret)) {
             Yii::$app->config->set(Enum::LINKED_IN_AUTH, LinkedIn::className());
             Yii::$app->config->set(Enum::LINKED_IN_CLIENT_ID, $model->linkedInClientId);
             Yii::$app->config->set(Enum::LINKED_IN_CLIENT_SECRET, $model->linkedInClientSecret);
             $config['components']['authClientCollection']['clients']['linkedin']['class'] = LinkedIn::className();
             $config['components']['authClientCollection']['clients']['linkedin']['clientId'] = $model->linkedInClientId;
             $config['components']['authClientCollection']['clients']['linkedin']['clientSecret'] = $model->linkedInClientSecret;
         } else {
             Yii::$app->config->set(Enum::LINKED_IN_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['linkedin']);
         }
         if (!empty($model->githubClientId) && !empty($model->githubClientSecret)) {
             Yii::$app->config->set(Enum::GITHUB_AUTH, GitHub::className());
             Yii::$app->config->set(Enum::GITHUB_CLIENT_ID, $model->githubClientId);
             Yii::$app->config->set(Enum::GITHUB_CLIENT_SECRET, $model->githubClientSecret);
             $config['components']['authClientCollection']['clients']['github']['class'] = GitHub::className();
             $config['components']['authClientCollection']['clients']['github']['clientId'] = $model->githubClientId;
             $config['components']['authClientCollection']['clients']['github']['clientSecret'] = $model->githubClientSecret;
         } else {
             Yii::$app->config->set(Enum::GITHUB_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['github']);
         }
         if (!empty($model->liveClientId) && !empty($model->liveClientSecret)) {
             Yii::$app->config->set(Enum::LIVE_AUTH, Live::className());
             Yii::$app->config->set(Enum::LIVE_CLIENT_ID, $model->liveClientId);
             Yii::$app->config->set(Enum::LIVE_CLIENT_SECRET, $model->liveClientSecret);
             $config['components']['authClientCollection']['clients']['live']['class'] = Live::className();
             $config['components']['authClientCollection']['clients']['live']['clientId'] = $model->liveClientId;
             $config['components']['authClientCollection']['clients']['live']['clientSecret'] = $model->liveClientSecret;
         } else {
             Yii::$app->config->set(Enum::LIVE_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['live']);
         }
         if (!empty($model->twitterConsumerKey) && !empty($model->twitterConsumerSecret)) {
             Yii::$app->config->set(Enum::TWITTER_AUTH, Twitter::className());
             Yii::$app->config->set(Enum::TWITTER_CONSUMER_KEY, $model->twitterConsumerKey);
             Yii::$app->config->set(Enum::TWITTER_CONSUMER_SECRET, $model->twitterConsumerSecret);
             $config['components']['authClientCollection']['clients']['twitter']['class'] = Twitter::className();
             $config['components']['authClientCollection']['clients']['twitter']['consumerKey'] = $model->twitterConsumerKey;
             $config['components']['authClientCollection']['clients']['twitter']['consumerSecret'] = $model->twitterConsumerSecret;
         } else {
             Yii::$app->config->set(Enum::TWITTER_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['twitter']);
         }
         Configuration::set($config);
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User module settings saved successfully'));
     }
     return $this->render('authClient', ['model' => $model]);
 }
Example #15
0
 /** @inheritdoc */
 public function bootstrap($app)
 {
     /** @var $module Module */
     if ($app->hasModule('users') && ($module = $app->getModule('users')) instanceof Module) {
         $this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
         foreach ($this->_modelMap as $name => $definition) {
             $class = "mii\\modules\\users\\models\\" . $name;
             \Yii::$container->set($class, $definition);
             $modelName = is_array($definition) ? $definition['class'] : $definition;
             $module->modelMap[$name] = $modelName;
             if (in_array($name, ['User', 'Profile', 'Token', 'Account'])) {
                 \Yii::$container->set($name . 'Query', function () use($modelName) {
                     return $modelName::find();
                 });
             }
         }
         \Yii::$container->setSingleton(Finder::className(), ['userQuery' => \Yii::$container->get('UserQuery'), 'profileQuery' => \Yii::$container->get('ProfileQuery'), 'tokenQuery' => \Yii::$container->get('TokenQuery'), 'accountQuery' => \Yii::$container->get('AccountQuery')]);
         if ($app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'mii\\modules\\users\\commands';
             $app->get('i18n')->translations['users*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         } else {
             try {
                 $app->user->enableAutoLogin = true;
                 $app->user->loginUrl = ['/users/security/login'];
                 $app->user->identityClass = $module->modelMap['User'];
             } catch (InvalidConfigException $e) {
                 $app->set('user', ['class' => User::className(), 'enableAutoLogin' => true, 'loginUrl' => ['/users/security/login'], 'identityClass' => $module->modelMap['User']]);
             }
             $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules];
             if ($module->urlPrefix != 'users') {
                 $configUrlRule['routePrefix'] = 'users';
             }
             $app->get('urlManager')->rules[] = new GroupUrlRule($configUrlRule);
             $app->get('urlManager')->addRules(['PUT,PATCH /' . $this->id . '/apis/<id>' => $this->id . '/api/update', 'DELETE /' . $this->id . '/apis/<id>' => $this->id . '/api/delete', 'GET,HEAD /' . $this->id . '/apis/<id>' => $this->id . '/api/view', 'POST /' . $this->id . '/apis' => $this->id . '/api/create', 'GET,HEAD /' . $this->id . '/apis' => $this->id . '/api/index', 'OPTIONS /' . $this->id . '/apis/<id>' => $this->id . '/api/options', 'OPTIONS /' . $this->id . '/apis' => $this->id . '/api/options'], false);
             if (!$app->has('authClientCollection')) {
                 $app->set('authClientCollection', ['class' => Collection::className()]);
             }
         }
         $app->get('i18n')->translations['users*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         $defaults = ['welcomeSubject' => \Yii::t('users', 'Welcome to {0}', \Yii::$app->name), 'confirmationSubject' => \Yii::t('users', 'Confirm account on {0}', \Yii::$app->name), 'reconfirmationSubject' => \Yii::t('users', 'Confirm email change on {0}', \Yii::$app->name), 'recoverySubject' => \Yii::t('users', 'Complete password reset on {0}', \Yii::$app->name)];
         \Yii::$container->set('mii\\modules\\users\\Mailer', array_merge($defaults, $module->mailer));
     }
 }
Example #16
0
<?php

$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'app-frontend', 'name' => 'diadoo', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\\controllers', 'modules' => ['user' => ['as frontend' => 'dektrium\\user\\filters\\FrontendFilter', 'modelMap' => ['Account' => 'frontend\\models\\Account', 'LoginForm' => 'frontend\\models\\LoginForm', 'Profile' => 'frontend\\models\\Profile', 'RecoveryForm' => 'frontend\\models\\RecoveryForm', 'RegistrationForm' => 'frontend\\models\\RegistrationForm', 'ResendForm' => 'frontend\\models\\ResendForm', 'SettingsForm' => 'frontend\\models\\SettingsForm', 'Token' => 'frontend\\models\\Token', 'User' => 'frontend\\models\\User'], 'controllerMap' => ['profile' => 'frontend\\controllers\\user\\ProfileController', 'recovery' => 'frontend\\controllers\\user\\RecoveryController', 'registration' => 'frontend\\controllers\\user\\RegistrationController', 'security' => 'frontend\\controllers\\user\\SecurityController', 'settings' => 'frontend\\controllers\\user\\SettingsController']]], 'components' => ['user' => ['identityCookie' => ['name' => '_frontendIdentity', 'path' => 'http://diadoo.me/frontend/web/', 'httpOnly' => true]], 'session' => ['name' => 'FRONTENDSESSID', 'cookieParams' => ['httpOnly' => true, 'path' => 'http://diadoo.me/frontend/web/']], 'view' => ['theme' => ['pathMap' => ['@dektrium/user/views' => '@app/views/user']]], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['facebook' => ['class' => 'dektrium\\user\\clients\\Facebook', 'clientId' => '1547326xxxxxxxx', 'clientSecret' => 'c6190dcd3f310xxxxxxxxxxx'], 'twitter' => ['class' => 'dektrium\\user\\clients\\Twitter', 'consumerKey' => '5HK13urUrYHSgAxxxxxxxxxxxx', 'consumerSecret' => 'thl4zLXiBASdewsQUFCCRBavhfYipEP3SeFxxxxxxxxx']]]], 'params' => $params];
Example #17
0
<?php

$config = ['components' => ['request' => ['cookieValidationKey' => ''], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['facebook' => ['class' => 'dektrium\\user\\clients\\Facebook', 'clientId' => '411786309019199', 'clientSecret' => '84b4d3cbe052826e46ad94d7e799e996', 'scope' => 'user_about_me user_photos email user_hometown', 'attributeNames' => ['id', 'name', 'email', 'picture', 'gender', 'hometown']]]]]];
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module'];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module'];
}
return $config;
Example #18
0
<?php

$common = ['id' => 'app', 'language' => 'en', 'basePath' => dirname(__DIR__), 'vendorPath' => '@app/../vendor', 'runtimePath' => '@app/../runtime', 'bootstrap' => ['log'], 'aliases' => ['@admin-views' => '@app/modules/backend/views'], 'components' => ['assetManager' => ['dirMode' => YII_ENV_PROD ? 0777 : null, 'bundles' => YII_ENV_PROD ? require __DIR__ . '/assets-gen/prod.php' : [], 'basePath' => '@app/../web/assets', 'converter' => ['class' => 'nizsheanez\\assetConverter\\Converter', 'parsers' => ['less' => ['class' => 'nizsheanez\\assetConverter\\Less', 'output' => 'css', 'options' => []]]]], 'authManager' => ['class' => 'yii\\rbac\\DbManager'], 'authClientCollection' => ['class' => \yii\authclient\Collection::className(), 'clients' => ['github' => ['class' => 'dektrium\\user\\clients\\GitHub', 'clientId' => '2c6657465ee42a24cb8e', 'clientSecret' => '60fea54543bdc8d666cb2ea8a217e632d61738ac']]], 'cache' => ['class' => 'yii\\caching\\FileCache'], 'db' => ['class' => 'yii\\db\\Connection', 'dsn' => getenv('DATABASE_DSN'), 'username' => getenv('DATABASE_USER'), 'password' => getenv('DATABASE_PASSWORD'), 'charset' => 'utf8', 'tablePrefix' => getenv('DATABASE_TABLE_PREFIX'), 'enableSchemaCache' => YII_ENV_PROD ? true : false], 'i18n' => ['translations' => ['*' => ['class' => 'yii\\i18n\\DbMessageSource', 'db' => 'db', 'sourceLanguage' => 'en', 'sourceMessageTable' => '{{%language_source}}', 'messageTable' => '{{%language_translate}}', 'cachingDuration' => 86400, 'enableCaching' => YII_DEBUG ? false : true]]], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'useFileTransport' => YII_ENV_PROD ? false : true], 'urlManager' => ['class' => 'codemix\\localeurls\\UrlManager', 'enablePrettyUrl' => getenv('APP_PRETTY_URLS') ? true : false, 'showScriptName' => getenv('YII_ENV_TEST') ? true : false, 'enableDefaultLanguageUrlCode' => true, 'baseUrl' => '/', 'rules' => [['class' => 'yii\\rest\\UrlRule', 'controller' => ['templates/api/v1/template']], 'docs/<file:[a-zA-Z0-9_\\-\\./]+>' => 'docs', 'POST api/v1/template/view/<id>' => 'templates/api/v1/template/process'], 'languages' => ['en', 'de']], 'user' => ['class' => 'app\\components\\User', 'enableAutoLogin' => true, 'loginUrl' => null, 'identityClass' => 'app\\models\\User'], 'view' => ['theme' => ['pathMap' => ['@vendor/dektrium/yii2-user/views/admin' => '@app/views/user/admin', '@yii/gii/views/layouts' => '@admin-views/layouts']]], 'fslocal' => ['class' => 'creocoder\\flysystem\\LocalFilesystem', 'path' => '@webroot/../files']], 'modules' => ['backend' => ['class' => 'app\\modules\\backend\\Module', 'layout' => '@admin-views/layouts/main'], 'docs' => ['class' => 'schmunk42\\markdocs\\Module', 'layout' => '@admin-views/layouts/box', 'markdownUrl' => '@app/../docs', 'forkUrl' => false], 'templates' => ['class' => 'app\\modules\\templates\\Module'], 'events' => ['class' => 'app\\modules\\event\\Module'], 'pages' => ['class' => 'dmstr\\modules\\pages\\Module', 'layout' => '@admin-views/layouts/main', 'availableViews' => ['@vendor/dmstr/yii2-pages-module/example-views/column1.php' => 'One Column']], 'user' => ['class' => 'dektrium\\user\\Module', 'layout' => '@app/views/layouts/container', 'defaultRoute' => 'profile', 'admins' => ['admin'], 'enableFlashMessages' => false], 'rbac' => ['class' => 'dektrium\\rbac\\Module', 'layout' => '@admin-views/layouts/box', 'enableFlashMessages' => false], 'translatemanager' => ['class' => 'lajax\\translatemanager\\Module', 'root' => '@app/views', 'layout' => '@admin-views/layouts/box', 'allowedIPs' => ['*'], 'roles' => ['admin', 'translate-manager']], 'treemanager' => ['class' => '\\kartik\\tree\\Module', 'layout' => '@admin-views/layouts/main', 'treeViewSettings' => ['nodeView' => '@vendor/dmstr/yii2-pages-module/views/treeview/_form', 'fontAwesome' => true]]], 'params' => ['appName' => getenv('APP_NAME'), 'adminEmail' => getenv('APP_ADMIN_EMAIL'), 'supportEmail' => getenv('APP_SUPPORT_EMAIL'), 'yii.migrations' => ['@yii/rbac/migrations', '@dektrium/user/migrations', '@vendor/lajax/yii2-translate-manager/migrations', '@app/modules/templates/migrations', '@app/modules/event/migrations']]];
$web = ['components' => ['errorHandler' => ['errorAction' => 'site/error'], 'log' => ['targets' => [['class' => 'codemix\\streamlog\\Target', 'url' => 'php://stdout', 'levels' => ['info', 'trace'], 'logVars' => [], 'enabled' => YII_DEBUG], ['class' => 'codemix\\streamlog\\Target', 'url' => 'php://stderr', 'levels' => ['error', 'warning'], 'logVars' => []]]], 'request' => ['cookieValidationKey' => getenv('APP_COOKIE_VALIDATION_KEY'), 'parsers' => ['application/json' => 'yii\\web\\JsonParser']], 'user' => ['identityClass' => 'dektrium\\user\\models\\User']]];
$console = ['controllerNamespace' => 'app\\commands', 'controllerMap' => ['migrate' => 'dmstr\\console\\controllers\\MigrateController', 'yaml' => 'dmstr\\console\\controllers\\DockerStackConverterController', 'translate' => '\\lajax\\translatemanager\\commands\\TranslatemanagerController'], 'components' => []];
$allowedIPs = ['127.0.0.1', '::1', '192.168.*', '172.17.*'];
// detecting current application type based on `php_sapi_name()` since we've no application ready yet.
if (php_sapi_name() == 'cli') {
    // Console application
    $config = \yii\helpers\ArrayHelper::merge($common, $console);
} else {
    // Web application
    if (YII_ENV_DEV) {
        // configuration adjustments for web 'dev' environment
        $common['bootstrap'][] = 'debug';
        $common['modules']['debug'] = ['class' => 'yii\\debug\\Module', 'allowedIPs' => $allowedIPs];
    }
    $config = \yii\helpers\ArrayHelper::merge($common, $web);
}
if (YII_ENV_DEV || YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module', 'allowedIPs' => $allowedIPs];
}
if (file_exists(__DIR__ . '/local.php')) {
    // Local configuration, if available
    $local = (require __DIR__ . '/local.php');
    $config = \yii\helpers\ArrayHelper::merge($config, $local);
}
return $config;