diff --git a/composer.json b/composer.json index 16636a5..cadfc88 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "bower-asset/bootstrap": "*", "npm-asset/jquery": "^3.5", "bower-asset/jquery": "^3.5", - "pbazsi/yii2-arangodb": "2.0", + "explosivebit/arangodb": "^2.0", "triagens/arangodb": "^3.6" }, "require-dev": { @@ -39,7 +39,10 @@ "autoload": { "psr-4": { "mirzaev\\skillparts\\": "mirzaev/skillparts/system" - } + }, + "classmap": [ + "vendor/explosivebit" + ] }, "autoload-dev": { "psr-4": { @@ -86,14 +89,14 @@ { "type": "package", "package": { - "name": "pbazsi/yii2-arangodb", - "version": "2.0", - "source": { - "type" : "git", - "url" : "https://github.com/pBazsi/yii2-arangodb.git", - "reference" : "master" - } + "name": "explosivebit/arangodb", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/pBazsi/yii2-arangodb.git", + "reference": "master" + } } - } + } ] -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index d0f597f..a13ca13 100644 --- a/composer.lock +++ b/composer.lock @@ -4,14 +4,14 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5c6fa00f67028dbc18572600d2a1935d", + "content-hash": "d83ed7a25bd848237d6ae45b945471f6", "packages": [ { "name": "bower-asset/bootstrap", "version": "v3.4.1", "source": { "type": "git", - "url": "git@github.com:twbs/bootstrap.git", + "url": "https://github.com/twbs/bootstrap.git", "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e" }, "dist": { @@ -302,6 +302,16 @@ ], "time": "2020-11-14T15:56:27+00:00" }, + { + "name": "explosivebit/arangodb", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/pBazsi/yii2-arangodb.git", + "reference": "master" + }, + "type": "library" + }, { "name": "ezyang/htmlpurifier", "version": "v4.13.0", @@ -364,16 +374,6 @@ "MIT" ] }, - { - "name": "pBazsi/yii2-arangodb", - "version": "2.0", - "source": { - "type": "git", - "url": "https://github.com/pBazsi/yii2-arangodb.git", - "reference": "master" - }, - "type": "library" - }, { "name": "swiftmailer/swiftmailer", "version": "v6.2.4", @@ -1835,21 +1835,21 @@ }, { "name": "codeception/verify", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/Codeception/Verify.git", - "reference": "11fa56c223ae7188174c4ba50c68454d83b254e9" + "reference": "1cdac1867c33801ae8e4833015153766ef403c92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Verify/zipball/11fa56c223ae7188174c4ba50c68454d83b254e9", - "reference": "11fa56c223ae7188174c4ba50c68454d83b254e9", + "url": "https://api.github.com/repos/Codeception/Verify/zipball/1cdac1867c33801ae8e4833015153766ef403c92", + "reference": "1cdac1867c33801ae8e4833015153766ef403c92", "shasum": "" }, "require": { "ext-dom": "*", - "php": "^7.3", + "php": "^7.3 || ^8.0", "phpunit/phpunit": "^9.3" }, "type": "library", @@ -1876,7 +1876,7 @@ } ], "description": "BDD assertion library for PHPUnit", - "time": "2020-09-03T04:43:01+00:00" + "time": "2020-12-18T16:18:31+00:00" }, { "name": "doctrine/instantiator", @@ -1945,16 +1945,16 @@ }, { "name": "fakerphp/faker", - "version": "v1.12.1", + "version": "v1.13.0", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "841e8bdde345cc1ea9f98e776959e7531cadea0e" + "reference": "ab3f5364d01f2c2c16113442fb987d26e4004913" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/841e8bdde345cc1ea9f98e776959e7531cadea0e", - "reference": "841e8bdde345cc1ea9f98e776959e7531cadea0e", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/ab3f5364d01f2c2c16113442fb987d26e4004913", + "reference": "ab3f5364d01f2c2c16113442fb987d26e4004913", "shasum": "" }, "require": { @@ -1989,11 +1989,7 @@ "faker", "fixtures" ], - "support": { - "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.12.1" - }, - "time": "2020-12-11T10:39:41+00:00" + "time": "2020-12-18T16:50:48+00:00" }, { "name": "guzzlehttp/psr7", @@ -2295,16 +2291,16 @@ }, { "name": "phar-io/version", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "726c026815142e4f8677b7cb7f2249c9ffb7ecae" + "reference": "e4782611070e50613683d2b9a57730e9a3ba5451" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/726c026815142e4f8677b7cb7f2249c9ffb7ecae", - "reference": "726c026815142e4f8677b7cb7f2249c9ffb7ecae", + "url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451", + "reference": "e4782611070e50613683d2b9a57730e9a3ba5451", "shasum": "" }, "require": { @@ -2338,7 +2334,7 @@ } ], "description": "Library for handling version information and constraints", - "time": "2020-11-30T09:21:21+00:00" + "time": "2020-12-13T23:18:30+00:00" }, { "name": "php-webdriver/webdriver", @@ -4142,16 +4138,16 @@ }, { "name": "symfony/browser-kit", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "4fc769a12282a12bc47f883f04f01ff3777e369b" + "reference": "87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/4fc769a12282a12bc47f883f04f01ff3777e369b", - "reference": "4fc769a12282a12bc47f883f04f01ff3777e369b", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a", + "reference": "87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a", "shasum": "" }, "require": { @@ -4192,9 +4188,6 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/browser-kit/tree/v5.2.0" - }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -4209,20 +4202,20 @@ "type": "tidelift" } ], - "time": "2020-11-14T11:04:29+00:00" + "time": "2020-12-18T08:03:05+00:00" }, { "name": "symfony/console", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3e0564fb08d44a98bd5f1960204c958e57bd586b" + "reference": "47c02526c532fb381374dab26df05e7313978976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3e0564fb08d44a98bd5f1960204c958e57bd586b", - "reference": "3e0564fb08d44a98bd5f1960204c958e57bd586b", + "url": "https://api.github.com/repos/symfony/console/zipball/47c02526c532fb381374dab26df05e7313978976", + "reference": "47c02526c532fb381374dab26df05e7313978976", "shasum": "" }, "require": { @@ -4303,20 +4296,20 @@ "type": "tidelift" } ], - "time": "2020-11-28T11:24:18+00:00" + "time": "2020-12-18T08:03:05+00:00" }, { "name": "symfony/css-selector", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "b8d8eb06b0942e84a69e7acebc3e9c1e6e6e7256" + "reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/b8d8eb06b0942e84a69e7acebc3e9c1e6e6e7256", - "reference": "b8d8eb06b0942e84a69e7acebc3e9c1e6e6e7256", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/f789e7ead4c79e04ca9a6d6162fc629c89bd8054", + "reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054", "shasum": "" }, "require": { @@ -4365,7 +4358,7 @@ "type": "tidelift" } ], - "time": "2020-10-28T21:31:18+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4433,16 +4426,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "0969122fe144dd8ab2e8c98c7e03eedc621b368c" + "reference": "ee7cf316fb0de786cfe5ae32ee79502b290c81ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/0969122fe144dd8ab2e8c98c7e03eedc621b368c", - "reference": "0969122fe144dd8ab2e8c98c7e03eedc621b368c", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/ee7cf316fb0de786cfe5ae32ee79502b290c81ea", + "reference": "ee7cf316fb0de786cfe5ae32ee79502b290c81ea", "shasum": "" }, "require": { @@ -4486,9 +4479,6 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/dom-crawler/tree/v5.2.0" - }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -4503,20 +4493,20 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:01:57+00:00" + "time": "2020-12-18T08:02:46+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "aa13a09811e6d2ad43f8fb336bebdb7691d85d3c" + "reference": "1c93f7a1dff592c252574c79a8635a8a80856042" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/aa13a09811e6d2ad43f8fb336bebdb7691d85d3c", - "reference": "aa13a09811e6d2ad43f8fb336bebdb7691d85d3c", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1c93f7a1dff592c252574c79a8635a8a80856042", + "reference": "1c93f7a1dff592c252574c79a8635a8a80856042", "shasum": "" }, "require": { @@ -4585,7 +4575,7 @@ "type": "tidelift" } ], - "time": "2020-11-01T16:14:45+00:00" + "time": "2020-12-18T08:03:05+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -4665,16 +4655,16 @@ }, { "name": "symfony/finder", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "fd8305521692f27eae3263895d1ef1571c71a78d" + "reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/fd8305521692f27eae3263895d1ef1571c71a78d", - "reference": "fd8305521692f27eae3263895d1ef1571c71a78d", + "url": "https://api.github.com/repos/symfony/finder/zipball/0b9231a5922fd7287ba5b411893c0ecd2733e5ba", + "reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba", "shasum": "" }, "require": { @@ -4719,7 +4709,7 @@ "type": "tidelift" } ], - "time": "2020-11-18T09:42:36+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5033,16 +5023,16 @@ }, { "name": "symfony/process", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "240e74140d4d956265048f3025c0aecbbc302d54" + "reference": "bd8815b8b6705298beaa384f04fabd459c10bedd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/240e74140d4d956265048f3025c0aecbbc302d54", - "reference": "240e74140d4d956265048f3025c0aecbbc302d54", + "url": "https://api.github.com/repos/symfony/process/zipball/bd8815b8b6705298beaa384f04fabd459c10bedd", + "reference": "bd8815b8b6705298beaa384f04fabd459c10bedd", "shasum": "" }, "require": { @@ -5088,7 +5078,7 @@ "type": "tidelift" } ], - "time": "2020-11-02T15:47:15+00:00" + "time": "2020-12-08T17:03:37+00:00" }, { "name": "symfony/service-contracts", @@ -5168,16 +5158,16 @@ }, { "name": "symfony/string", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "40e975edadd4e32cd16f3753b3bad65d9ac48242" + "reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/40e975edadd4e32cd16f3753b3bad65d9ac48242", - "reference": "40e975edadd4e32cd16f3753b3bad65d9ac48242", + "url": "https://api.github.com/repos/symfony/string/zipball/5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed", + "reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed", "shasum": "" }, "require": { @@ -5244,20 +5234,20 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:08:07+00:00" + "time": "2020-12-05T07:33:16+00:00" }, { "name": "symfony/yaml", - "version": "v5.2.0", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "bb73619b2ae5121bbbcd9f191dfd53ded17ae598" + "reference": "290ea5e03b8cf9b42c783163123f54441fb06939" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/bb73619b2ae5121bbbcd9f191dfd53ded17ae598", - "reference": "bb73619b2ae5121bbbcd9f191dfd53ded17ae598", + "url": "https://api.github.com/repos/symfony/yaml/zipball/290ea5e03b8cf9b42c783163123f54441fb06939", + "reference": "290ea5e03b8cf9b42c783163123f54441fb06939", "shasum": "" }, "require": { @@ -5316,7 +5306,7 @@ "type": "tidelift" } ], - "time": "2020-11-28T10:57:20+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "theseer/tokenizer", diff --git a/mirzaev/skillparts/system/assets/AppAsset.php b/mirzaev/skillparts/system/assets/AppAsset.php index 8362772..0984dc6 100644 --- a/mirzaev/skillparts/system/assets/AppAsset.php +++ b/mirzaev/skillparts/system/assets/AppAsset.php @@ -31,12 +31,14 @@ class AppAsset extends AssetBundle 'css/footer.css' ]; public $js = [ + 'https://kit.fontawesome.com/d7e922c226.js', 'https://code.jquery.com/jquery-3.5.1.min.js', 'js/bootstrap/popper.min.js', 'js/bootstrap/bootstrap.min.js', 'https://cdn.jsdelivr.net/bxslider/4.1.1/jquery.bxslider.min.js', + 'js/account.js', 'js/ticker.js', - 'https://kit.fontawesome.com/d7e922c226.js' + 'js/reinitialization.js' ]; public $depends = [ 'yii\web\YiiAsset', diff --git a/mirzaev/skillparts/system/config/console.php.example b/mirzaev/skillparts/system/config/console.php.example index 299656a..bfca8b6 100644 --- a/mirzaev/skillparts/system/config/console.php.example +++ b/mirzaev/skillparts/system/config/console.php.example @@ -1,17 +1,16 @@ 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'app\commands', 'aliases' => [ - '@bower' => '@vendor/bower-asset', - '@npm' => '@vendor/npm-asset', - '@tests' => '@app/tests', + '@vendor' => dirname(__DIR__) . '../../../../vendor', + '@bower' => '@vendor/bower-asset', + '@npm' => '@vendor/npm-asset', + '@explosivebit' => '@vendor/explosivebit', + '@tests' => '@app/tests', ], 'components' => [ 'cache' => [ @@ -25,16 +24,15 @@ $config = [ ], ], ], - 'db' => $db, + 'arangodb' => require __DIR__ . '/db.php' ], - 'params' => $params, - /* + 'params' => require __DIR__ . '/params.php', 'controllerMap' => [ - 'fixture' => [ // Fixture generation command line. + 'arangodb-migrate' => 'explosivebit\arangodb\console\controllers\MigrateController', + 'fixture' => [ 'class' => 'yii\faker\FixtureController', ], - ], - */ + ] ]; if (YII_ENV_DEV) { diff --git a/mirzaev/skillparts/system/config/db.php.example b/mirzaev/skillparts/system/config/db.php.example index 441fe79..c18864e 100644 --- a/mirzaev/skillparts/system/config/db.php.example +++ b/mirzaev/skillparts/system/config/db.php.example @@ -1,14 +1,14 @@ 'yii\db\Connection', - 'dsn' => 'mysql:host=;dbname=', - 'username' => '', - 'password' => '', - 'charset' => 'utf8', +use ArangoDBClient\ConnectionOptions; - // Schema cache options (for production environment) - //'enableSchemaCache' => true, - //'schemaCacheDuration' => 60, - //'schemaCache' => 'cache', +return [ + 'class' => '\explosivebit\arangodb\Connection', + 'connectionOptions' => [ + ConnectionOptions::OPTION_DATABASE => '', + ConnectionOptions::OPTION_ENDPOINT => 'tcp://127.0.0.1:8529', + ConnectionOptions::OPTION_AUTH_TYPE => 'Basic', + ConnectionOptions::OPTION_AUTH_USER => '', + ConnectionOptions::OPTION_AUTH_PASSWD => '', + ], ]; diff --git a/mirzaev/skillparts/system/config/test.php.example b/mirzaev/skillparts/system/config/test.php.example index f95bc03..2165565 100644 --- a/mirzaev/skillparts/system/config/test.php.example +++ b/mirzaev/skillparts/system/config/test.php.example @@ -1,6 +1,4 @@ 'en-US', 'components' => [ - 'db' => $db, + 'db' => require __DIR__ . '/test_db.php', 'mailer' => [ 'useFileTransport' => true, ], @@ -25,7 +23,7 @@ return [ 'showScriptName' => true, ], 'user' => [ - 'identityClass' => 'app\models\User', + 'identityClass' => 'app\models\Account', ], 'request' => [ 'cookieValidationKey' => 'test', @@ -38,5 +36,5 @@ return [ */ ], ], - 'params' => $params, + 'params' => require __DIR__ . '/params.php', ]; diff --git a/mirzaev/skillparts/system/config/web.php.example b/mirzaev/skillparts/system/config/web.php.example index a263153..9934e07 100644 --- a/mirzaev/skillparts/system/config/web.php.example +++ b/mirzaev/skillparts/system/config/web.php.example @@ -1,31 +1,34 @@ 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'aliases' => [ - '@vendor' => '../../../../vendor', - '@bower' => '@vendor/bower-asset', - '@npm' => '@vendor/npm-asset', + '@vendor' => dirname(__DIR__) . '../../../../vendor', + '@bower' => '@vendor/bower-asset', + '@npm' => '@vendor/npm-asset', + '@explosivebit' => '@vendor/explosivebit', ], 'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 'cookieValidationKey' => '', + 'baseUrl' => '' + ], + 'cache' => [ + 'class' => 'yii\caching\FileCache', ], - // 'cache' => [ - // 'class' => 'yii\caching\FileCache', - // ], 'user' => [ - 'identityClass' => 'app\models\User', + 'identityClass' => 'app\models\Account', 'enableAutoLogin' => true, ], + // 'session' => [ + // 'class' => 'yii\web\Session', + // 'cookieParams' => ['lifetime' => 3600 * 24 * 30 * 12], + // 'timeout' => 3600 * 24 * 30 * 12, + // 'useCookies' => true, + // ], 'errorHandler' => [ 'errorAction' => 'site/error', ], @@ -45,32 +48,29 @@ $config = [ ], ], ], - 'db' => $db, - 'arangodb' => [ - 'class' => '\explosivebit\arangodb\Connection', - 'connectionOptions' => [ - ConnectionOptions::OPTION_DATABASE => '', - ConnectionOptions::OPTION_ENDPOINT => '', - ConnectionOptions::OPTION_AUTH_TYPE => 'Basic', - ConnectionOptions::OPTION_AUTH_USER => '', - ConnectionOptions::OPTION_AUTH_PASSWD => '', - ], - ], + 'arangodb' => require __DIR__ . '/db.php', 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, - 'rules' => [], + 'rules' => [ + ['class' => 'yii\rest\UrlRule', 'controller' => 'site'], + '' => 'site/' + ], ], ], - 'params' => $params, + 'params' => require __DIR__ . '/params.php', ]; if (YII_ENV_DEV) { - // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', + 'panels' => [ + 'ArangoDB' => [ + 'class' => 'explosivebit\arangodb\panels\arangodb\ArangoDbPanel' + ] + ], // uncomment the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.0.1', '::1'], ]; diff --git a/mirzaev/skillparts/system/controllers/SiteController.php b/mirzaev/skillparts/system/controllers/SiteController.php index 6e8a85d..bd9eeec 100644 --- a/mirzaev/skillparts/system/controllers/SiteController.php +++ b/mirzaev/skillparts/system/controllers/SiteController.php @@ -7,11 +7,14 @@ use yii\filters\AccessControl; use yii\web\Controller; use yii\web\Response; use yii\filters\VerbFilter; -use app\models\LoginForm; +use app\models\AuthenticationForm; +use app\models\RegistrationForm; use app\models\ContactForm; +use app\models\Account; class SiteController extends Controller { + /** * {@inheritdoc} */ @@ -19,7 +22,7 @@ class SiteController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'only' => ['logout'], 'rules' => [ [ @@ -30,7 +33,7 @@ class SiteController extends Controller ], ], 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'logout' => ['post'], ], @@ -64,26 +67,94 @@ class SiteController extends Controller return $this->render('index'); } + /** + * Identification action. + * + * @return Response + */ + public function actionIdentification() + { + if (Yii::$app->request->isAjax) { + Yii::$app->response->format = Response::FORMAT_JSON; + + if (Yii::$app->user->isGuest) { + return [ + 'menu' => 'Вход', + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } else { + $mail = Yii::$app->user->identity->mail; + + return [ + 'menu' => << + + + Выход ($mail) +

+ HTML, + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + } + } + /** * Login action. * * @return Response|string */ - public function actionLogin() + public function actionAuthentication() { - if (!Yii::$app->user->isGuest) { - return $this->goHome(); + $model = new AuthenticationForm(Yii::$app->request->post()['AuthenticationForm'] ?? Yii::$app->request->get()['AuthenticationForm']); + + if (Yii::$app->request->isAjax) { + // AJAX-POST-запрос + + if (!Yii::$app->user->isGuest) { + // Аккаунт уже авторизован + Yii::$app->response->statusCode = 403; + return [ + 'form' => $this->renderPartial('index'), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + + Yii::$app->response->format = Response::FORMAT_JSON; + + if (isset($model->mail, $model->pswd)) { + if ($model->load(Yii::$app->request->post()) && $model->authentication()) { + return [ + 'menu' => << + + + Выход ($model->mail) +

+ HTML, + 'form' => $this->renderPartial('index'), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + } else { + return [ + 'menu' => 'Вход', + 'form' => $this->renderPartial('authentication', compact('model')), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + } else if (Yii::$app->request->isPost) { + // POST-запрос + } else { + // GET-запрос и прочие + + if (!Yii::$app->user->isGuest) { + // Аккаунт уже авторизован + Yii::$app->response->redirect('/'); + } } - $model = new LoginForm(); - if ($model->load(Yii::$app->request->post()) && $model->login()) { - return $this->goBack(); - } - - $model->password = ''; - return $this->render('login', [ - 'model' => $model, - ]); + return $this->render('authentication', compact('model')); } /** @@ -91,11 +162,101 @@ class SiteController extends Controller * * @return Response */ - public function actionLogout() + public function actionDeauthentication() { - Yii::$app->user->logout(); + if (Yii::$app->request->isAjax) { + // AJAX-POST-запрос - return $this->goHome(); + Yii::$app->response->format = Response::FORMAT_JSON; + Yii::$app->user->logout(); + + return [ + 'menu' => 'Вход', + 'form' => $this->renderPartial('index'), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + + Yii::$app->response->redirect('/'); + } + + /** + * Login action. + * + * @return Response|string + */ + public function actionRegistration() + { + $model = new RegistrationForm(Yii::$app->request->post()['RegistrationForm'] ?? Yii::$app->request->get()['RegistrationForm']); + + if (Yii::$app->request->isAjax) { + // AJAX-POST-запрос + + if (!Yii::$app->user->isGuest) { + // Аккаунт уже авторизован + Yii::$app->response->statusCode = 302; + return [ + 'form' => $this->renderPartial('index'), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + + Yii::$app->response->format = Response::FORMAT_JSON; + + if (isset($model->mail, $model->pswd)) { + // Аккаунт передал необходимые параметры + + // Инициализация нового аккаунта + $account = new Account(); + $account->mail = $model->mail; + $account->pswd = Yii::$app->security->generatePasswordHash($model->pswd); + + if ($model->load(Yii::$app->request->post()) && $model->validate() && $account->save()) { + // Данные прошли проверку и аккаунт был создан + + return [ + 'menu' => << + + + Выход ($account->mail) +

+ HTML, + 'form' => $this->renderPartial('index'), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } else { + // Данные не прошли проверку + + Yii::$app->response->statusCode = 400; + + return [ + 'form' => $this->renderPartial('registration', compact('model')), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + } else { + // Аккаунт не передал необходимые параметры + + return [ + 'menu' => 'Вход', + 'form' => $this->renderPartial('registration', compact('model')), + '_csrf' => Yii::$app->request->getCsrfToken() + ]; + } + } else if (Yii::$app->request->isPost) { + // POST-запрос + return; + } else { + // GET-запрос и прочие + + if (!Yii::$app->user->isGuest) { + // Аккаунт уже авторизован + Yii::$app->response->redirect('/'); + } + } + + return $this->render('registration', compact('model')); } /** diff --git a/mirzaev/skillparts/system/migrations/arangodb/m201219_074926_create_account_collection.php b/mirzaev/skillparts/system/migrations/arangodb/m201219_074926_create_account_collection.php new file mode 100644 index 0000000..f35cb13 --- /dev/null +++ b/mirzaev/skillparts/system/migrations/arangodb/m201219_074926_create_account_collection.php @@ -0,0 +1,20 @@ +createCollection('account'); + } + + public function down() + { + // $this->delete('accounts', 'mail'); + // $this->delete('accounts', 'name'); + // $this->delete('accounts', 'pswd'); + + $this->dropCollection('account'); + } +} diff --git a/mirzaev/skillparts/system/models/Account.php b/mirzaev/skillparts/system/models/Account.php new file mode 100644 index 0000000..576325b --- /dev/null +++ b/mirzaev/skillparts/system/models/Account.php @@ -0,0 +1,115 @@ + 'sex', 'simc', 'sity', 'comp', 'taxn', 'auth']; + } + + /** + * @return int|string current user ID + */ + public function getId() + { + return $this->mail; + } + + /** + * @return string current user auth key + */ + public function getAuthKey() + { + return $this->auth; + } + + /** + * Finds an identity by the given ID. + * + * @param string|int $id the ID to be looked for + * @return IdentityInterface|null the identity object that matches the given ID. + */ + public static function findIdentity($mail) + { + return static::findOne(['mail' => $mail]); + } + + /** + * Finds an identity by the given token. + * + * @param string $token the token to be looked for + * @return IdentityInterface|null the identity object that matches the given token. + */ + public static function findIdentityByAccessToken($pass, $type = null) + { + return static::findOne(['pass' => $pass]); + } + + /** + * Finds user by mail + * + * @param string $mail + * @return static|null + */ + public static function findByMail($mail) + { + return static::findOne(['mail' => $mail]); + } + + /** + * Validates password + * + * @param string $pswd password to validate + * @return bool if password provided is valid for current user + */ + public function validatePassword($pswd) + { + return Yii::$app->security->validatePassword($pswd, $this->pswd); + } + + /** + * @param string $auth + * @return bool if auth key is valid for current user + */ + public function validateAuthKey($auth) + { + return $this->getAuthKey() === $auth; + } + + public function beforeSave($insert) + { + if (parent::beforeSave($insert)) { + if ($this->isNewRecord) { + $this->auth = Yii::$app->security->generateRandomString(); + } + return true; + } + return false; + } +} diff --git a/mirzaev/skillparts/system/models/AuthenticationForm.php b/mirzaev/skillparts/system/models/AuthenticationForm.php new file mode 100644 index 0000000..24b2425 --- /dev/null +++ b/mirzaev/skillparts/system/models/AuthenticationForm.php @@ -0,0 +1,91 @@ + 'Почта', + 'pswd' => 'Пароль', + 'auto' => 'Запомнить' + ]; + } + + /** + * Validates the password. + * This method serves as the inline validation for password. + * + * @param string $attribute the attribute currently being validated + * @param array $params the additional name-value pairs given in the rule + */ + public function validatePassword($attribute, $params) + { + if (!$this->hasErrors()) { + $account = $this->getAccount(); + + if (!$account || !$account->validatePassword($this->pswd)) { + $this->addError($attribute, 'Не удалось идентифицировать'); + } + } + } + + /** + * Logs in a account using the provided accountname and password. + * @return bool whether the account is logged in successfully + */ + public function authentication() + { + if ($this->validate()) { + return Yii::$app->user->login($this->getAccount(), $this->auto ? 3600*24*30 : 0); + } + return false; + } + + /** + * Finds account by [[accountname]] + * + * @return Account|null + */ + public function getAccount() + { + if ($this->account === false) { + $this->account = Account::findByMail($this->mail); + } + + return $this->account; + } +} diff --git a/mirzaev/skillparts/system/models/LoginForm.php b/mirzaev/skillparts/system/models/LoginForm.php deleted file mode 100644 index 66d6580..0000000 --- a/mirzaev/skillparts/system/models/LoginForm.php +++ /dev/null @@ -1,81 +0,0 @@ -hasErrors()) { - $user = $this->getUser(); - - if (!$user || !$user->validatePassword($this->password)) { - $this->addError($attribute, 'Incorrect username or password.'); - } - } - } - - /** - * Logs in a user using the provided username and password. - * @return bool whether the user is logged in successfully - */ - public function login() - { - if ($this->validate()) { - return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); - } - return false; - } - - /** - * Finds user by [[username]] - * - * @return User|null - */ - public function getUser() - { - if ($this->_user === false) { - $this->_user = User::findByUsername($this->username); - } - - return $this->_user; - } -} diff --git a/mirzaev/skillparts/system/models/RegistrationForm.php b/mirzaev/skillparts/system/models/RegistrationForm.php new file mode 100644 index 0000000..23364b0 --- /dev/null +++ b/mirzaev/skillparts/system/models/RegistrationForm.php @@ -0,0 +1,28 @@ + 'Заполните поле'], + ['mail', 'unique', 'targetClass' => Account::class, 'message' => 'Почта уже привязана к другому аккаунту'], + ]; + } + + public function attributeLabels() + { + return [ + 'mail' => 'Почта', + 'pswd' => 'Пароль', + ]; + } +} diff --git a/mirzaev/skillparts/system/views/layouts/main.php b/mirzaev/skillparts/system/views/layouts/main.php index caf7fd3..cb989ba 100644 --- a/mirzaev/skillparts/system/views/layouts/main.php +++ b/mirzaev/skillparts/system/views/layouts/main.php @@ -17,7 +17,7 @@ AppAsset::register($this); registerCsrfMetaTags() ?> - <?= Html::encode($this->title) ?> + <?= Html::encode($this->title ?? 'SkillParts') ?> head() ?> @@ -28,13 +28,11 @@ AppAsset::register($this);
@@ -72,7 +70,7 @@ AppAsset::register($this); -->
@@ -100,9 +98,6 @@ AppAsset::register($this); Поставщикам Партнерская сеть - diff --git a/mirzaev/skillparts/system/views/site/login.php b/mirzaev/skillparts/system/views/site/authentication.php similarity index 58% rename from mirzaev/skillparts/system/views/site/login.php rename to mirzaev/skillparts/system/views/site/authentication.php index 0944d37..eb8d1b1 100644 --- a/mirzaev/skillparts/system/views/site/login.php +++ b/mirzaev/skillparts/system/views/site/authentication.php @@ -8,35 +8,39 @@ use yii\helpers\Html; use yii\bootstrap\ActiveForm; $this->title = 'Login'; -$this->params['breadcrumbs'][] = $this->title; ?> + + \ No newline at end of file diff --git a/mirzaev/skillparts/system/views/site/index.php b/mirzaev/skillparts/system/views/site/index.php index e2a8b50..673d4c4 100644 --- a/mirzaev/skillparts/system/views/site/index.php +++ b/mirzaev/skillparts/system/views/site/index.php @@ -8,7 +8,7 @@ $this->title = 'SkillParts';

Проблема с подбором запчастей?

- + Связаться с менеджером
Связаться с менеджером diff --git a/mirzaev/skillparts/system/views/site/registration.php b/mirzaev/skillparts/system/views/site/registration.php new file mode 100644 index 0000000..f293303 --- /dev/null +++ b/mirzaev/skillparts/system/views/site/registration.php @@ -0,0 +1,21 @@ + + + 'form_registration', + 'action' => false, + 'options' => [ + 'onsubmit' => 'registration(this); return false;' + ] +]) ?> +field($model, 'mail') ?> +field($model, 'pswd')->passwordInput() ?> +
+
+ 'btn btn-success']) ?> +
+
+ \ No newline at end of file diff --git a/mirzaev/skillparts/system/web/Nginx_1.17_vhost.conf b/mirzaev/skillparts/system/web/Nginx_1.17_vhost.conf index 689e574..6dbea9f 100644 --- a/mirzaev/skillparts/system/web/Nginx_1.17_vhost.conf +++ b/mirzaev/skillparts/system/web/Nginx_1.17_vhost.conf @@ -18,15 +18,15 @@ ssl_certificate_key '%sprogdir%/userdata/config/cert_files/server.key' # ssl_trusted_certificate ''; # Force HTTPS -# add_header Strict-Transport-Security 'max-age=2592000' always; -# if ($scheme ~* ^(?!https).*$) { -# return 301 https://$host$request_uri; -# } +add_header Strict-Transport-Security 'max-age=2592000' always; +if ($scheme ~* ^(?!https).*$) { + return 301 https://$host$request_uri; +} # Force www.site.com => site.com -# if ($host ~* ^www\.(.+)$) { -# return 301 $scheme://$1$request_uri; -# } +if ($host ~* ^www\.(.+)$) { + return 301 $scheme://$1$request_uri; +} # Disable access to backup/config/command/log files # if ($uri ~* ^.+\.(?:bak|co?nf|in[ci]|log|orig|sh|sql|tar|sql|t?gz|cmd|bat)$) { @@ -70,38 +70,6 @@ location / { include '%sprogdir%/userdata/config/nginx_fastcgi_params.txt'; } } - -# Service configuration (do not edit!) -# ---------------------------- -location /openserver/ { - root '%sprogdir%/modules/system/html'; - autoindex off; - index index.php index.html index.htm; - - %allow%allow all; - allow 127.0.0.0/8; - allow ::1/128; - allow %ips%; - deny all; - - location ~* ^/openserver/.+\.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|svgz?|ttf|ttc|otf|eot|woff2?)$ { - expires 1d; - access_log off; - } - - location /openserver/server-status { - stub_status on; - } - - location ~ ^/openserver/.*\.php$ { - try_files $fastcgi_script_name =404; - fastcgi_index index.php; - fastcgi_pass backend; - include '%sprogdir%/userdata/config/nginx_fastcgi_params.txt'; - } -} -# End service configuration -# ---------------------------- } # ---------------------------- diff --git a/mirzaev/skillparts/system/web/css/ticker.css b/mirzaev/skillparts/system/web/css/ticker.css index 2dbe819..46be2b7 100644 --- a/mirzaev/skillparts/system/web/css/ticker.css +++ b/mirzaev/skillparts/system/web/css/ticker.css @@ -8,5 +8,5 @@ .bx-wrapper .bx-viewport { width: 100vw !important; - height: 4rem !important; + height: 2rem !important; } \ No newline at end of file diff --git a/mirzaev/skillparts/system/web/js/account.js b/mirzaev/skillparts/system/web/js/account.js new file mode 100644 index 0000000..aa84db9 --- /dev/null +++ b/mirzaev/skillparts/system/web/js/account.js @@ -0,0 +1,113 @@ +function identification() { + $.ajax({ + url: '/identification', + type: 'post', + dataType: 'json', + data: { '_csrf': yii.getCsrfToken() }, + success: function (data) { + // Обновление документа + document.getElementById('nav').innerHTML = data.menu; + $('meta[name=csrf-token]').prop("content", data._csrf); + + // Реинициализация + reinitialization(); + } + }); +}; + +function authentication(form) { + if (form == undefined) { + form = { '_csrf': yii.getCsrfToken() }; + } else { + form = $(form).serialize(); + } + + $.ajax({ + url: '/authentication', + type: 'post', + dataType: 'json', + data: form, + success: function (data, status) { + // Обновление документа + document.getElementById('nav').innerHTML = data.menu; + document.getElementsByTagName('main')[0].innerHTML = data.form; + $('meta[name=csrf-token]').prop("content", data._csrf); + + // Перенаправление + history.pushState({}, document.title, '/'); + + // Реинициализация + reinitialization(); + }, + error: function (data, status) { + // Обновление документа + document.getElementsByTagName('main')[0].innerHTML = data.responseJSON.form; + $('meta[name=csrf-token]').prop("content", data.responseJSON._csrf); + + if (statis === 403) { + // Перенаправление + history.pushState({}, document.title, '/'); + } + + // Реинициализация + reinitialization(); + } + }); +}; + +function deauthentication() { + $.ajax({ + url: '/deauthentication', + type: 'post', + dataType: 'json', + data: { '_csrf': yii.getCsrfToken() }, + success: function (data) { + // Обновление документа + document.getElementById('nav').innerHTML = data.menu; + document.getElementsByTagName('main')[0].innerHTML = data.form; + $('meta[name=csrf-token]').prop("content", data._csrf); + + // Перенаправление + history.pushState({}, document.title, '/'); + + // Реинициализация + reinitialization(); + } + }); +}; + +function registration(form) { + $.ajax({ + url: '/registration', + type: 'post', + dataType: 'json', + data: $(form).serialize(), + success: function (data) { + // Обновление документа + document.getElementById('nav').innerHTML = data.menu; + document.getElementsByTagName('main')[0].innerHTML = data.form; + $('meta[name=csrf-token]').prop("content", data._csrf); + + // Перенаправление + history.pushState({}, document.title, '/'); + + // Реинициализация + reinitialization(); + }, + error: function (data) { + // Обновление документа + document.getElementsByTagName('main')[0].innerHTML = data.responseJSON.form; + $('meta[name=csrf-token]').prop("content", data.responseJSON._csrf); + + if (statis === 403) { + // Перенаправление + history.pushState({}, document.title, '/'); + } + + // Реинициализация + reinitialization(); + } + }); +}; + +document.addEventListener('DOMContentLoaded', identification(), true); \ No newline at end of file diff --git a/mirzaev/skillparts/system/web/js/reinitialization.js b/mirzaev/skillparts/system/web/js/reinitialization.js new file mode 100644 index 0000000..b3d2b49 --- /dev/null +++ b/mirzaev/skillparts/system/web/js/reinitialization.js @@ -0,0 +1,5 @@ +function reinitialization() { + // Функции которые должны быть запущены при инициализации документа + + tickerInit('all'); +} \ No newline at end of file diff --git a/mirzaev/skillparts/system/web/js/ticker.js b/mirzaev/skillparts/system/web/js/ticker.js index 5dfd4c2..1f350ef 100644 --- a/mirzaev/skillparts/system/web/js/ticker.js +++ b/mirzaev/skillparts/system/web/js/ticker.js @@ -1,8 +1,15 @@ -$('.ticker').bxSlider({ - minSlides: 1, - maxSlides: 18, - slideWidth: 189, - slideMargin: 0, - ticker: true, - speed: 50000 -}); \ No newline at end of file +function tickerInit(ticker) { + ticker = $('.ticker').bxSlider({ + minSlides: 1, + maxSlides: 100, + slideMargin: 0, + ticker: true, + speed: 80000 + }); +} + +function tickerReinit(ticker) { + ticker.reloadSlider(); +} + +document.addEventListener('DOMContentLoaded', tickerInit(), true); \ No newline at end of file