From a57ab294109abdd674a8269573e876c47ddd8ef2 Mon Sep 17 00:00:00 2001 From: viper-vlad Date: Sat, 16 Oct 2021 16:36:07 +0600 Subject: [PATCH] fix: user auth token --- src/Chat.php | 2 +- src/Users/User.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Chat.php b/src/Chat.php index 51f0b98..be7014c 100644 --- a/src/Chat.php +++ b/src/Chat.php @@ -40,7 +40,7 @@ public static function login($userName, $password, $auth = true) static::setAuthToken(static::getResponse()->data->authToken); } - return User::createOutOfResponse(static::getResponse()->data->me); + return User::createOutOfResponse(static::getResponse()->data); } /** diff --git a/src/Users/User.php b/src/Users/User.php index fd372ad..c16c64f 100644 --- a/src/Users/User.php +++ b/src/Users/User.php @@ -11,6 +11,19 @@ class User extends Request { use Data; + public function setUserAuthToken($token){ + $this->authToken = $token; + } + + public static function createOutOfResponse($response) + { + $user = new self($response->me->_id); + $user->setUserAuthToken($response->authToken); + + return $user->updateOutOfResponse($response->me); + } + + /** * Gets user listing *