From f7a4697b35bc092b8e784dff5a2a490b86bef688 Mon Sep 17 00:00:00 2001 From: smarcet Date: Mon, 23 Mar 2020 22:33:28 -0300 Subject: [PATCH] Fixed null pointer exception Change-Id: I69b99548696c020ef7f10e2a4b98af66b53408e0 Signed-off-by: smarcet --- app/libs/Auth/Models/User.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/libs/Auth/Models/User.php b/app/libs/Auth/Models/User.php index 46f178f7..f2b2fdc3 100644 --- a/app/libs/Auth/Models/User.php +++ b/app/libs/Auth/Models/User.php @@ -20,6 +20,7 @@ use Illuminate\Support\Facades\Event; use App\Events\UserEmailVerified; use Doctrine\Common\Collections\Criteria; use Illuminate\Auth\Authenticatable; +use Illuminate\Support\Facades\Log; use models\exceptions\ValidationException; use Models\OAuth2\ApiScope; use Models\OAuth2\Client; @@ -804,6 +805,18 @@ class User extends BaseEntity */ public function checkPassword(string $password): bool { + if(empty($this->password)) + { + Log::warning(sprintf("User %s (%s) has not password set.", $this->id, $this->email)); + return false; + } + + if(empty($this->password_enc)) + { + Log::warning(sprintf("User %s (%s) has not password encoding set.", $this->id, $this->email)); + return false; + } + return AuthHelper::check($password, $this->password, $this->password_enc, $this->password_salt); }