From 884f04ac642d7c316f0fafe58a69355e12c98847 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Tue, 3 Dec 2024 22:48:07 +0000 Subject: [PATCH] fix: disable password auth when using fromOAuth --- src/Auth.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index bfc8412..c939ece 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -336,17 +336,25 @@ public function updatePassword(string $oldPassword, string $newPassword): bool */ public function fromOAuth(array $userData): bool { - $this->checkDbConnection(); + $initialPassword = Config::get('password.key'); - Config::setUserCache('oauth-token', $userData['token']); + $this->checkDbConnection(); + $this->config('password.key', false); $user = $this->db->select(Config::get('db.table'))->where($userData['user'])->first(); + Config::setUserCache('oauth-token', $userData['token']); + if (!$user) { - return $this->register($userData['user']); + $success = $this->register($userData['user']); + $this->config('password.key', $initialPassword); + + return $success; } $this->user = new User($user); + $this->config('password.key', $initialPassword); + return true; }