{"id":5040,"date":"2021-08-09T09:38:59","date_gmt":"2021-08-09T09:38:59","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=5040"},"modified":"2021-08-09T09:38:59","modified_gmt":"2021-08-09T09:38:59","slug":"yii-autentifikacziya","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/uk\/yii-autentifikacziya\/","title":{"rendered":"Yii \u2014 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043b\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f&nbsp;<strong>\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439<\/strong>&nbsp;.&nbsp;\u041e\u0431\u044b\u0447\u043d\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0434\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0435\u043c, \u043d\u0430 \u043a\u043e\u0433\u043e \u043e\u043d \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0443 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 Yii, \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li><li>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 yii \\ web \\ IdentityInterface.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.&nbsp;\u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $params = require(__DIR__ . '\/params.php');\n   $config = [\n      'id' =&gt; 'basic',\n      'basePath' =&gt; dirname(__DIR__),\n      'bootstrap' =&gt; ['log'],\n      'components' =&gt; [\n         'request' =&gt; [\n            \/\/ !!! insert a secret key in the following (if it is empty) - this\n               \/\/is required by cookie validation\n            'cookieValidationKey' =&gt; 'ymoaYrebZHa8gURuolioHGlK8fLXCKjO',\n         ],\n         'cache' =&gt; [\n            'class' =&gt; 'yii\\caching\\FileCache',\n         ],\n         'user' =&gt; [\n            'identityClass' =&gt; 'app\\models\\User',\n            'enableAutoLogin' =&gt; true,\n         ],\n         \/\/other components...\n         'db' =&gt; require(__DIR__ . '\/db.php'),\n      ],\n      'modules' =&gt; [\n         'hello' =&gt; [\n            'class' =&gt; 'app\\modules\\hello\\Hello',\n         ],\n      ],\n      'params' =&gt; $params,\n   ];\n   if (YII_ENV_DEV) {\n      \/\/ configuration adjustments for 'dev' environment\n      $config['bootstrap'][] = 'debug';\n      $config['modules']['debug'] = [\n         'class' =&gt; 'yii\\debug\\Module',\n      ];\n      $config['bootstrap'][] = 'gii';\n      $config['modules']['gii'] = [\n         'class' =&gt; 'yii\\gii\\Module',\n      ];\n   }\n   return $config;\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043a\u0430\u043a app \\ models \\ User.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043b\u0430\u0441\u0441 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c&nbsp;<strong>\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 yii \\ web \\ IdentityInterface<\/strong>&nbsp;\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>findIdentity ()<\/strong>&nbsp;\u2014 \u0438\u0449\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/li><li><strong>findIdentityByAccessToken ()<\/strong>&nbsp;\u2014 \u0438\u0449\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/li><li><strong>getId ()<\/strong>&nbsp;\u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/li><li><strong>getAuthKey ()<\/strong>&nbsp;\u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u044e\u0447, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435&nbsp;<strong>\u0444\u0430\u0439\u043b\u043e\u0432<\/strong>&nbsp;cookie.<\/li><li><strong>validateAuthKey ()<\/strong>&nbsp;\u2014 \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043b\u044e\u0447\u0430 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 cookie.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>findIdentity ()<\/strong>&nbsp;\u2014 \u0438\u0449\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>findIdentityByAccessToken ()<\/strong>&nbsp;\u2014 \u0438\u0449\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>getId ()<\/strong>&nbsp;\u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>getAuthKey ()<\/strong>&nbsp;\u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u044e\u0447, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435&nbsp;<strong>\u0444\u0430\u0439\u043b\u043e\u0432<\/strong>&nbsp;cookie.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>validateAuthKey ()<\/strong>&nbsp;\u2014 \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043b\u044e\u0447\u0430 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 cookie.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041c\u043e\u0434\u0435\u043b\u044c User \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.\u00a0\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u00a0<strong>$ users<\/strong>\u00a0\u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   namespace app\\models;\n   class User extends \\yii\\base\\Object implements \\yii\\web\\IdentityInterface {\n      public $id;\n      public $username;\n      public $password;\n      public $authKey;\n      public $accessToken;\n      private static $users = [\n         '100' =&gt; [\n            'id' =&gt; '100',\n            'username' =&gt; 'admin',\n            'password' =&gt; 'admin',\n            'authKey' =&gt; 'test100key',\n            'accessToken' =&gt; '100-token',\n         ],\n         '101' =&gt; [\n            'id' =&gt; '101',\n            'username' =&gt; 'demo',\n            'password' =&gt; 'demo',\n            'authKey' =&gt; 'test101key',\n            'accessToken' =&gt; '101-token',\n         ],\n      ];\n      \/**\n      * @inheritdoc\n      *\/\n      public static function findIdentity($id) {\n         return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;\n      }\n      \/**\n      * @inheritdoc\n      *\/\n      public static function findIdentityByAccessToken($token, $type = null) {\n         foreach (self::$users as $user) {\n            if ($user['accessToken'] === $token) {\n               return new static($user);\n            }\n         }\n         return null;\n      }\n      \/**\n      * Finds user by username\n      *\n      * @param string $username\n      * @return static|null\n      *\/\n      public static function findByUsername($username) {\n         foreach (self::$users as $user) {\n            if (strcasecmp($user['username'], $username) === 0) {\n               return new static($user);\n            }\n         }\n         return null;\n      }\n      \/**\n      * @inheritdoc\n      *\/\n      public function getId() {\n         return $this-&gt;id;\n      }\n      \/**\n      * @inheritdoc\n      *\/\n      public function getAuthKey() {\n         return $this-&gt;authKey;\n      }\n      \/**\n      * @inheritdoc\n      *\/\n      public function validateAuthKey($authKey) {\n         return $this-&gt;authKey === $authKey;\n      }\n      \/**\n      * Validates password \n      *\n      * @param string $password password to validate\n      * @return boolean if password provided is valid for current user\n      *\/\n      public function validatePassword($password) {\n         return $this-&gt;password === $password;\n      }\n   }\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0428\u0430\u0433 1<\/strong>&nbsp;\u2014 \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e URL-\u0430\u0434\u0440\u0435\u0441\u0443&nbsp;<strong>http: \/\/ localhost: 8080 \/ index.php? R = site \/ login<\/strong>&nbsp;\u0438 \u0432\u043e\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f admin \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u043f\u0430\u0440\u043e\u043b\u044f.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/admin_login.png\" alt=\"\u041b\u043e\u0433\u0438\u043d \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0428\u0430\u0433 2<\/strong>&nbsp;\u2014 \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;<strong>actionAuth ()<\/strong>&nbsp;\u0432 SiteController.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public function actionAuth(){\n   \/\/ the current user identity. Null if the user is not authenticated.\n   $identity = Yii::$app-&gt;user-&gt;identity;\n   var_dump($identity);\n   \/\/ the ID of the current user. Null if the user not authenticated.\n   $id = Yii::$app-&gt;user-&gt;id;\n   var_dump($id);\n   \/\/ whether the current user is a guest (not authenticated)\n   $isGuest = Yii::$app-&gt;user-&gt;isGuest;\n   var_dump($isGuest);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0428\u0430\u0433 3<\/strong>&nbsp;\u2014 \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0430\u0434\u0440\u0435\u0441&nbsp;<strong>http: \/\/ localhost: 8080 \/ index.php? R = site \/ auth<\/strong>&nbsp;\u0432 \u0432\u0435\u0431-\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431&nbsp;<strong>\u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0435<\/strong>&nbsp;\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/actionauth_method.png\" alt=\"\u041c\u0435\u0442\u043e\u0434 actionAuth\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0428\u0430\u0433 4<\/strong>&nbsp;\u2014 \u0414\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public function actionAuth() {\n   \/\/ whether the current user is a guest (not authenticated)\n   var_dump(Yii::$app-&gt;user-&gt;isGuest);\n   \/\/ find a user identity with the specified username.\n   \/\/ note that you may want to check the password if needed\n   $identity = User::findByUsername(\"admin\");\n   \/\/ logs in the user\n   Yii::$app-&gt;user-&gt;login($identity);\n   \/\/ whether the current user is a guest (not authenticated)\n   var_dump(Yii::$app-&gt;user-&gt;isGuest);\n   Yii::$app-&gt;user-&gt;logout();\n   \/\/ whether the current user is a guest (not authenticated)\n   var_dump(Yii::$app-&gt;user-&gt;isGuest);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u043e\u0448\u0435\u043b \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442&nbsp;<strong>false<\/strong>&nbsp;, \u0442\u043e \u043c\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430&nbsp;<strong>Yii :: $ app \u2192 user \u2192 login ()<\/strong>&nbsp;\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e&nbsp;<strong>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Yii :: $ app. \u2192 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u2192 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b ()<\/strong>&nbsp;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0428\u0430\u0433 5<\/strong>&nbsp;\u2014 \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e URL&nbsp;<strong>http: \/\/ localhost: 8080 \/ index.php? R = site \/ auth<\/strong>&nbsp;, \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/verifying_user_login.png\" alt=\"\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043b\u0430\u0441\u0441&nbsp;<strong>yii \\ web \\ User<\/strong>&nbsp;\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>EVENT_BEFORE_LOGIN<\/strong>&nbsp;\u2014&nbsp;<strong>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/strong>&nbsp;\u0432 \u043d\u0430\u0447\u0430\u043b\u0435&nbsp;<em>yii \\ web \\ User :: login ()<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>EVENT_AFTER_LOGIN<\/strong>&nbsp;\u2014&nbsp;<strong>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/strong>&nbsp;\u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>EVENT_BEFORE_LOGOUT<\/strong>&nbsp;\u2014&nbsp;<strong>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/strong>&nbsp;\u0432 \u043d\u0430\u0447\u0430\u043b\u0435&nbsp;<em>yii \\ web \\ User :: logout ()<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>EVENT_AFTER_LOGOUT<\/strong>&nbsp;\u2014&nbsp;<strong>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/strong>&nbsp;\u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043b\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f&nbsp;\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439&nbsp;.&nbsp;\u041e\u0431\u044b\u0447\u043d\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0434\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0435\u043c, \u043d\u0430 \u043a\u043e\u0433\u043e \u043e\u043d [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[156],"tags":[],"class_list":["post-5040","page","type-page","status-publish","hentry","category-yii"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/5040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/comments?post=5040"}],"version-history":[{"count":1,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/5040\/revisions"}],"predecessor-version":[{"id":5041,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/5040\/revisions\/5041"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/media?parent=5040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/categories?post=5040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/tags?post=5040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}