diff --git a/backend/config/main.php b/backend/config/main.php index 7af9726..1fca45d 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -35,17 +35,21 @@ 'variant-option-complementary' => 'artbox\catalog\controllers\VariantOptionComplController', 'variant-option-exclusion' => 'artbox\catalog\controllers\VariantOptionExclController', 'product-option-complementary' => 'artbox\catalog\controllers\ProductOptionComplController', - 'product-option-exclusion' => 'artbox\catalog\controllers\ProductOptionExclController', - 'import' => 'artbox\catalog\controllers\ImportController', - 'blog-article' => 'artbox\weblog\controllers\ArticleController', - 'blog-category' => 'artbox\weblog\controllers\CategoryController', - 'blog-tag' => 'artbox\weblog\controllers\TagController', - 'order' => 'artbox\order\controllers\OrderController', - 'order-product' => 'artbox\order\controllers\OrderProductController', - 'label' => 'artbox\order\controllers\LabelController', - 'delivery' => 'artbox\order\controllers\DeliveryController', - 'payment' => 'artbox\order\controllers\PaymentController', - 'sitemap' => 'artbox\core\controllers\SitemapController', + 'product-option-exclusion' => 'artbox\catalog\controllers\ProductOptionExclController', + 'import' => 'artbox\catalog\controllers\ImportController', + 'blog-article' => 'artbox\weblog\controllers\ArticleController', + 'blog-category' => 'artbox\weblog\controllers\CategoryController', + 'blog-tag' => 'artbox\weblog\controllers\TagController', + 'order' => 'artbox\order\controllers\OrderController', + 'order-product' => 'artbox\order\controllers\OrderProductController', + 'label' => 'artbox\order\controllers\LabelController', + 'delivery' => 'artbox\order\controllers\DeliveryController', + 'payment' => 'artbox\order\controllers\PaymentController', + 'sitemap' => 'artbox\core\controllers\SitemapController', + 'comment' => [ + 'class' => 'artbox\webcomment\controllers\ManageController', + 'viewPath' => '@artbox/webcomment/views/manage', + ], ], 'components' => [ 'assetManager' => [ diff --git a/common/config/main.php b/common/config/main.php index 1ab54d9..0f86266 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -52,6 +52,10 @@ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@artbox/webcomment/messages', ], + 'eauth' => [ + 'class' => 'yii\i18n\PhpMessageSource', + 'basePath' => '@eauth/messages', + ], ], ], 'filedb' => [ diff --git a/composer.json b/composer.json index f1653e6..4f5e606 100755 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "bower-asset/amcharts": "@dev", "bower-asset/pnotify": "@dev", "kartik-v/yii2-widget-colorinput": "*", - "kartik-v/yii2-widget-datepicker": "@dev" + "kartik-v/yii2-widget-datepicker": "@dev", + "nodge/yii2-eauth": "~2.0" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", diff --git a/composer.lock b/composer.lock index 625eb57..8ca1958 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "5df5513d6efdd9ab201fd9f3e65ba409", + "content-hash": "f43dbc89b0b20b177ad04a1c8c260992", "packages": [ { "name": "2amigos/yii2-tinymce-widget", @@ -575,16 +575,16 @@ }, { "name": "ezyang/htmlpurifier", - "version": "v4.9.2", + "version": "v4.9.3", "source": { "type": "git", "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "6d50e5282afdfdfc3e0ff6d192aff56c5629b3d4" + "reference": "95e1bae3182efc0f3422896a3236e991049dac69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/6d50e5282afdfdfc3e0ff6d192aff56c5629b3d4", - "reference": "6d50e5282afdfdfc3e0ff6d192aff56c5629b3d4", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/95e1bae3182efc0f3422896a3236e991049dac69", + "reference": "95e1bae3182efc0f3422896a3236e991049dac69", "shasum": "" }, "require": { @@ -618,7 +618,7 @@ "keywords": [ "html" ], - "time": "2017-03-13T06:30:53+00:00" + "time": "2017-06-03T02:28:16+00:00" }, { "name": "firebase/php-jwt", @@ -1545,6 +1545,68 @@ "time": "2017-04-12 09:00:24" }, { + "name": "lusitanian/oauth", + "version": "v0.3.6", + "source": { + "type": "git", + "url": "https://github.com/Lusitanian/PHPoAuthLib.git", + "reference": "4ce8c488971410233eb3b1e6d9ac4e81debb41d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/4ce8c488971410233eb3b1e6d9ac4e81debb41d5", + "reference": "4ce8c488971410233eb3b1e6d9ac4e81debb41d5", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "predis/predis": "0.8.*@dev", + "symfony/http-foundation": "~2.1" + }, + "suggest": { + "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.", + "predis/predis": "Allows using the Redis storage backend.", + "symfony/http-foundation": "Allows using the Symfony Session storage backend." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } + }, + "autoload": { + "psr-0": { + "OAuth": "src", + "OAuth\\Unit": "tests" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Desberg", + "email": "david@daviddesberg.com" + }, + { + "name": "Pieter Hordijk", + "email": "info@pieterhordijk.com" + } + ], + "description": "PHP 5.3+ oAuth 1/2 Library", + "keywords": [ + "Authentication", + "authorization", + "oauth", + "security" + ], + "time": "2015-09-09T06:43:02+00:00" + }, + { "name": "monolog/monolog", "version": "1.22.1", "source": { @@ -1718,6 +1780,105 @@ "time": "2016-11-29T18:17:37+00:00" }, { + "name": "nodge/lightopenid", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/Nodge/LightOpenID.git", + "reference": "a5492cc0c932c557b7e9b54a6e5bbd85cc5fa041" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nodge/LightOpenID/zipball/a5492cc0c932c557b7e9b54a6e5bbd85cc5fa041", + "reference": "a5492cc0c932c557b7e9b54a6e5bbd85cc5fa041", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "autoload": { + "classmap": [ + "openid.php", + "provider/provider.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT License" + ], + "authors": [ + { + "name": "Mewp", + "homepage": "http://code.google.com/p/lightopenid/" + }, + { + "name": "Ignat Ignatov", + "homepage": "https://github.com/iignatov/LightOpenID" + } + ], + "description": "Lightweight PHP5 library for easy OpenID authentication.", + "homepage": "https://github.com/Nodge/LightOpenID", + "keywords": [ + "Authentication", + "OpenId" + ], + "time": "2013-08-31T16:48:56+00:00" + }, + { + "name": "nodge/yii2-eauth", + "version": "2.5.0", + "source": { + "type": "git", + "url": "https://github.com/Nodge/yii2-eauth.git", + "reference": "04798651fdb3a0db9ed5272330f18b26733507a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nodge/yii2-eauth/zipball/04798651fdb3a0db9ed5272330f18b26733507a0", + "reference": "04798651fdb3a0db9ed5272330f18b26733507a0", + "shasum": "" + }, + "require": { + "lib-curl": "*", + "lusitanian/oauth": "~0.3.0", + "nodge/lightopenid": "~1.1.0", + "php": ">=5.4.0", + "yiisoft/yii2": "*" + }, + "type": "yii2-extension", + "extra": { + "bootstrap": "nodge\\eauth\\Bootstrap" + }, + "autoload": { + "psr-4": { + "nodge\\eauth\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "New BSD License" + ], + "authors": [ + { + "name": "Maxim Zemskov", + "email": "nodge@yandex.ru", + "homepage": "http://nodge.ru/" + } + ], + "description": "Yii2 EAuth Extension. EAuth allows to authenticate users with accounts on other websites (Google, Facebook, Twitter, etc).", + "homepage": "https://github.com/Nodge/yii2-eauth", + "keywords": [ + "Authentication", + "OpenId", + "eauth", + "extension", + "oauth", + "yii2" + ], + "time": "2017-04-09T20:23:01+00:00" + }, + { "name": "phpoffice/phpexcel", "version": "1.8.1", "source": { @@ -1776,16 +1937,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "f8dd0e18d2328c447dd4190fecd11ef52680d968" + "reference": "34a7699e6f31b1ef4035ee36444407cecf9f56aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/f8dd0e18d2328c447dd4190fecd11ef52680d968", - "reference": "f8dd0e18d2328c447dd4190fecd11ef52680d968", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/34a7699e6f31b1ef4035ee36444407cecf9f56aa", + "reference": "34a7699e6f31b1ef4035ee36444407cecf9f56aa", "shasum": "" }, "require": { @@ -1864,7 +2025,7 @@ "x.509", "x509" ], - "time": "2017-05-08T05:58:35+00:00" + "time": "2017-06-05T06:31:10+00:00" }, { "name": "psr/cache", @@ -2253,21 +2414,21 @@ }, { "name": "yiisoft/yii2", - "version": "2.0.11.2", + "version": "2.0.12", "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-framework.git", - "reference": "ee996adec1dfd7babb67bd0c604f5bd6425fe5ab" + "reference": "70acbecc75cb26b6cd66d16be0b06e4b73db190d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/ee996adec1dfd7babb67bd0c604f5bd6425fe5ab", - "reference": "ee996adec1dfd7babb67bd0c604f5bd6425fe5ab", + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/70acbecc75cb26b6cd66d16be0b06e4b73db190d", + "reference": "70acbecc75cb26b6cd66d16be0b06e4b73db190d", "shasum": "" }, "require": { "bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable", - "bower-asset/jquery.inputmask": "~3.2.2 | ~3.3.3", + "bower-asset/jquery.inputmask": "~3.2.2 | ~3.3.5", "bower-asset/punycode": "1.3.*", "bower-asset/yii2-pjax": "~2.0.1", "cebe/markdown": "~1.0.0 | ~1.1.0", @@ -2349,7 +2510,7 @@ "framework", "yii2" ], - "time": "2017-02-08T09:04:32+00:00" + "time": "2017-06-05T14:33:41+00:00" }, { "name": "yiisoft/yii2-bootstrap", @@ -3568,16 +3729,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.2.0", + "version": "6.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "23bcb03e5c6a8b8067f6c2b28f6cd84b2df321cc" + "reference": "16999a1e9a8a25d68f0ab8cc8ab818b043ad5374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/23bcb03e5c6a8b8067f6c2b28f6cd84b2df321cc", - "reference": "23bcb03e5c6a8b8067f6c2b28f6cd84b2df321cc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/16999a1e9a8a25d68f0ab8cc8ab818b043ad5374", + "reference": "16999a1e9a8a25d68f0ab8cc8ab818b043ad5374", "shasum": "" }, "require": { @@ -3622,7 +3783,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1.x-dev" + "dev-master": "6.2.x-dev" } }, "autoload": { @@ -3648,7 +3809,7 @@ "testing", "xunit" ], - "time": "2017-06-02T08:02:48+00:00" + "time": "2017-06-02T12:24:37+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -4315,7 +4476,7 @@ }, { "name": "symfony/browser-kit", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", @@ -4372,16 +4533,16 @@ }, { "name": "symfony/console", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c80e63f3f5e3a331bfc25e6e9332b10422eb9b05" + "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c80e63f3f5e3a331bfc25e6e9332b10422eb9b05", - "reference": "c80e63f3f5e3a331bfc25e6e9332b10422eb9b05", + "url": "https://api.github.com/repos/symfony/console/zipball/70d2a29b2911cbdc91a7e268046c395278238b2e", + "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e", "shasum": "" }, "require": { @@ -4394,6 +4555,7 @@ }, "require-dev": { "psr/log": "~1.0", + "symfony/config": "~3.3", "symfony/dependency-injection": "~3.3", "symfony/event-dispatcher": "~2.8|~3.0", "symfony/filesystem": "~2.8|~3.0", @@ -4436,11 +4598,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-05-28T14:08:56+00:00" + "time": "2017-06-02T19:24:58+00:00" }, { "name": "symfony/css-selector", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -4493,16 +4655,16 @@ }, { "name": "symfony/debug", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "ef5f19a7a68075a0bd05969a329ead3b0776fb7a" + "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/ef5f19a7a68075a0bd05969a329ead3b0776fb7a", - "reference": "ef5f19a7a68075a0bd05969a329ead3b0776fb7a", + "url": "https://api.github.com/repos/symfony/debug/zipball/e9c50482841ef696e8fa1470d950a79c8921f45d", + "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d", "shasum": "" }, "require": { @@ -4545,11 +4707,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-05-27T16:02:27+00:00" + "time": "2017-06-01T21:01:25+00:00" }, { "name": "symfony/dom-crawler", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -4605,16 +4767,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a9f8b02b0ef07302eca92cd4bba73200b7980e9c" + "reference": "4054a102470665451108f9b59305c79176ef98f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a9f8b02b0ef07302eca92cd4bba73200b7980e9c", - "reference": "a9f8b02b0ef07302eca92cd4bba73200b7980e9c", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4054a102470665451108f9b59305c79176ef98f0", + "reference": "4054a102470665451108f9b59305c79176ef98f0", "shasum": "" }, "require": { @@ -4664,20 +4826,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-05-04T12:23:07+00:00" + "time": "2017-06-04T18:15:29+00:00" }, { "name": "symfony/finder", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "30cb2a2c09627823a7243638dd456de4e2748fed" + "reference": "baea7f66d30854ad32988c11a09d7ffd485810c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/30cb2a2c09627823a7243638dd456de4e2748fed", - "reference": "30cb2a2c09627823a7243638dd456de4e2748fed", + "url": "https://api.github.com/repos/symfony/finder/zipball/baea7f66d30854ad32988c11a09d7ffd485810c4", + "reference": "baea7f66d30854ad32988c11a09d7ffd485810c4", "shasum": "" }, "require": { @@ -4713,7 +4875,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-05-25T23:10:31+00:00" + "time": "2017-06-01T21:01:25+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -4776,16 +4938,16 @@ }, { "name": "symfony/yaml", - "version": "v3.3.0", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "885db865f6b2b918404a1fae28f9ac640f71f994" + "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/885db865f6b2b918404a1fae28f9ac640f71f994", - "reference": "885db865f6b2b918404a1fae28f9ac640f71f994", + "url": "https://api.github.com/repos/symfony/yaml/zipball/9752a30000a8ca9f4b34b5227d15d0101b96b063", + "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063", "shasum": "" }, "require": { @@ -4827,7 +4989,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-05-28T10:56:20+00:00" + "time": "2017-06-02T22:05:06+00:00" }, { "name": "theseer/tokenizer", diff --git a/environments/index.php b/environments/index.php index 78384be..c3b62d2 100755 --- a/environments/index.php +++ b/environments/index.php @@ -4,7 +4,6 @@ * This file returns a list of environments that the application * may be installed under. The returned data must be in the following * format: - * * ```php * return [ * 'environment name' => [ @@ -36,6 +35,8 @@ 'backend/web/assets', 'frontend/runtime', 'frontend/web/assets', + 'storage', + 'common/config/settings.php', ], 'setExecutable' => [ 'yii', @@ -54,6 +55,8 @@ 'backend/web/assets', 'frontend/runtime', 'frontend/web/assets', + 'storage', + 'common/config/settings.php', ], 'setExecutable' => [ 'yii', diff --git a/frontend/config/eauth.php b/frontend/config/eauth.php new file mode 100644 index 0000000..aba9bae --- /dev/null +++ b/frontend/config/eauth.php @@ -0,0 +1,55 @@ + 'nodge\eauth\EAuth', + 'popup' => true, + 'cache' => false, + 'cacheExpire' => 0, + 'httpClient' => [ + // uncomment this to use streams in safe_mode + //'useStreamsFallback' => true, + ], + 'services' => [ + 'google' => [ + // register your app here: https://code.google.com/apis/console/ + 'class' => 'nodge\eauth\services\GoogleOAuth2Service', + 'clientId' => '857343172443-th52trcqruo6pct71hmn72pud8ob9c9o.apps.googleusercontent.com', + 'clientSecret' => 'PgQIYSOjEUm4lffk_o7zMhxZ', + 'title' => 'Google', + ], + 'facebook' => [ + // register your app here: https://developers.facebook.com/apps/ + 'class' => 'nodge\eauth\services\FacebookOAuth2Service', + 'clientId' => '1453788021358149', + 'clientSecret' => '97dc7b9863b482dce6c6e7618bda9738', + ], + 'yahoo' => [ + 'class' => 'nodge\eauth\services\YahooOpenIDService', + //'realm' => '*.example.org', // your domain, can be with wildcard to authenticate on subdomains. + ], + 'linkedin_oauth2' => [ + // register your app here: https://www.linkedin.com/secure/developer + 'class' => 'nodge\eauth\services\LinkedinOAuth2Service', + 'clientId' => '86uay6912iwzn7', + 'clientSecret' => 'IkOc8oMOlxkyNSfK', + 'title' => 'LinkedIn (OAuth2)', + ], + 'github' => [ + // register your app here: https://github.com/settings/applications + 'class' => 'nodge\eauth\services\GitHubOAuth2Service', + 'clientId' => '1a72fc01be1ecca28c76', + 'clientSecret' => '188376ae0736133bdca9f4376a99a1cd2a6e6254', + ], + 'steam' => [ + 'class' => 'nodge\eauth\services\SteamOpenIDService', + //'realm' => '*.example.org', // your domain, can be with wildcard to authenticate on subdomains. + 'apiKey' => 'ED8812C3AA509B94D4744AADBF4FDF49', + // Optional. You can get it here: https://steamcommunity.com/dev/apikey + ], + 'instagram' => [ + // register your app here: https://instagram.com/developer/register/ + 'class' => 'nodge\eauth\services\InstagramOAuth2Service', + 'clientId' => '7c3de0236bb4467bae58707012addce8', + 'clientSecret' => 'bfcf8a5eb47d4998b6e3dd573777a857', + ], + ], + ]; \ No newline at end of file diff --git a/frontend/config/main.php b/frontend/config/main.php index f2d4d3a..1346ea8 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -1,4 +1,5 @@ 'yii\log\FileTarget', + 'logFile' => '@frontend/runtime/logs/eauth.log', + 'categories' => [ + 'nodge\eauth\*', + ], + 'logVars' => [], + ], ], ], 'errorHandler' => [ @@ -68,9 +77,9 @@ 'route' => 'category/view', 'defaults' => [ 'filter' => '' ], ], - 'special/' => 'special/index', - 'special//' => 'special/category', - 'robots.txt' => 'site/robots', + 'special/' => 'special/index', + 'special//' => 'special/category', + 'robots.txt' => 'site/robots', [ 'pattern' => 'artbox-comment/manage/', 'route' => 'notfound', @@ -78,11 +87,16 @@ 'action' => '', ], ], + 'login/' => 'site/login', ], ], 'basket' => [ 'class' => Basket::className(), ], + 'eauth' => require( 'eauth.php' ), + 'history' => [ + 'class' => History::className(), + ], ], 'params' => $params, ]; diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index abab6ba..9f723a4 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -7,12 +7,15 @@ use artbox\catalog\models\Product; use artbox\core\models\DummyAlias; use artbox\core\models\Feedback; + use artbox\order\models\Customer; use artbox\order\models\LoginForm; use artbox\order\models\PasswordResetRequestForm; use artbox\order\models\ResetPasswordForm; use artbox\order\models\SignupForm; use artbox\weblog\models\Article; use common\models\Settings; + use nodge\eauth\ErrorException; + use nodge\eauth\openid\ControllerBehavior; use Yii; use yii\base\InvalidParamException; use yii\bootstrap\Html; @@ -50,6 +53,10 @@ 'feedback' => [ 'post' ], ], ], + 'eauth' => [ + 'class' => ControllerBehavior::className(), + 'only' => [ 'login' ], + ], ]; } @@ -90,6 +97,33 @@ ->is('mask', 4) ->limit(20) ->all(); + $historyItems = []; + /** + * @var \artbox\catalog\components\History $history + */ + if ($history = \Yii::$app->get('history', false)) { + if (!empty($history->get())) { + $historyItems = Product::find() + ->with('lang', 'image') + ->innerJoinWith( + [ + 'variants' => function ($query) { + /** + * @var \yii\db\ActiveQuery $query + */ + $query->with('image'); + }, + ] + ) + ->where( + [ + 'variant.id' => $history->get(), + ] + ) + ->limit(20) + ->all(); + } + } $productCount = Product::find() ->count(); $brandCount = Brand::find() @@ -124,6 +158,7 @@ 'topItems' => $topItems, 'newItems' => $newItems, 'saleItems' => $saleItems, + 'historyItems' => $historyItems, 'productCount' => $productCount, 'brandCount' => $brandCount, 'brands' => $brands, @@ -249,6 +284,44 @@ public function actionLogin() { + $serviceName = Yii::$app->getRequest() + ->getQueryParam('service'); + if (isset($serviceName)) { + /** @var $eauth \nodge\eauth\ServiceBase */ + $eauth = Yii::$app->get('eauth') + ->getIdentity($serviceName); + $eauth->setRedirectUrl( + Yii::$app->getUser() + ->getReturnUrl() + ); + $eauth->setCancelUrl( + Yii::$app->getUrlManager() + ->createAbsoluteUrl('site/login') + ); + + try { + if ($eauth->authenticate()) { + // var_dump($eauth->getIsAuthenticated(), $eauth->getAttributes()); exit; + $identity = Customer::findByEAuth($eauth); + Yii::$app->getUser() + ->login($identity); + + // special redirect with closing popup window + $eauth->redirect(); + } else { + // close popup window and redirect to cancelUrl + $eauth->cancel(); + } + } catch (ErrorException $e) { + // save error to show it later + Yii::$app->getSession() + ->setFlash('error', 'EAuthException: ' . $e->getMessage()); + + // close popup window and redirect to cancelUrl + // $eauth->cancel(); + $eauth->redirect($eauth->getCancelUrl()); + } + } if (!\Yii::$app->user->isGuest) { return $this->redirect([ 'index' ]); } diff --git a/frontend/controllers/VariantController.php b/frontend/controllers/VariantController.php index 500e7fb..c68da46 100755 --- a/frontend/controllers/VariantController.php +++ b/frontend/controllers/VariantController.php @@ -27,6 +27,12 @@ { $model = $this->findModel($id); /** + * @var \artbox\catalog\components\History $history + */ + if ($history = \Yii::$app->get('history', false)) { + $history->add($model->id); + } + /** * @var SeoComponent $seo */ $seo = Yii::$app->get('seo'); diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 17504d7..59cfc01 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -16,6 +16,7 @@ use common\models\Settings; use frontend\assets\AppAsset; use frontend\widgets\LangLink; + use nodge\eauth\Widget; use yii\base\Model; use yii\bootstrap\ActiveForm; use yii\bootstrap\Html; @@ -368,6 +369,19 @@ _________________________________________________________ --> +
+

+
+ + diff --git a/frontend/views/site/login.php b/frontend/views/site/login.php index 26201e5..6718592 100755 --- a/frontend/views/site/login.php +++ b/frontend/views/site/login.php @@ -2,9 +2,11 @@ /* @var $this yii\web\View */ /* @var $form yii\bootstrap\ActiveForm */ - /* @var $loginForm \common\models\LoginForm */ - /* @var $signupForm \common\models\SignupForm */ + /* @var $loginForm LoginForm */ + /* @var $signupForm SignupForm */ + use artbox\order\models\LoginForm; + use artbox\order\models\SignupForm; use yii\bootstrap\ActiveForm; use yii\bootstrap\Html; @@ -73,8 +75,15 @@


- +

Do you already have an account on one of these sites? Click the logo to log in with it here:

+ 'site/login' ]); ?> getSession() + ->hasFlash('error') + ) { + echo '
' . Yii::$app->getSession() + ->getFlash('error') . '
'; + } $formLogin = ActiveForm::begin(); echo $formLogin->field($loginForm, 'username') ->textInput(); -- libgit2 0.21.4