/** * Loads user from config */ private static function loadUsers() { if (is_null(self::$users)) { self::$users = (require '../config/users.php'); } }
/** * Validates password * * @param string $password password to validate * @return boolean if password provided is valid for current user */ public function validatePassword($password) { if (Yii::$app->getSecurity()->validatePassword($password, $this->usr_pass)) { $this->id = 100; $this->authKey = 'test100key'; $this->accessToken = '100-token'; self::$users = ['100' => ['id' => 100, 'username' => $this->usr_id, 'authKey' => 'test100key', 'accessToken' => '100-token']]; // self::$users->id=1; // self::$users->username=$DbUsers->usr_id; } else { $this->id = null; self::$users = ['100' => ['id' => null, 'username' => null, 'authKey' => 'test100key', 'accessToken' => '100-token']]; } return Yii::$app->getSecurity()->validatePassword($password, $this->usr_pass); // return $this->usr_pass === $password; }
/** * Finds user by username * * @param string $username * @return static|null */ public static function findByEmail($email) { self::$users = new User(); self::$users = User::find()->where(['email' => $email])->one(); return self::$users; }