diff --git a/src/Domains/Souk/Orders/DataTransferObject/Order.php b/src/Domains/Souk/Orders/DataTransferObject/Order.php index 145e8480e..5ce0a2695 100644 --- a/src/Domains/Souk/Orders/DataTransferObject/Order.php +++ b/src/Domains/Souk/Orders/DataTransferObject/Order.php @@ -23,7 +23,6 @@ public function __construct( public readonly CompanyInterface $company, public readonly People $people, public readonly UserInterface $user, - public readonly string $email, public readonly string $token, public readonly string $orderNumber, public readonly ?Address $shippingAddress, @@ -37,6 +36,7 @@ public function __construct( public readonly Currencies $currency, #[DataCollectionOf(OrderItem::class)] public readonly DataCollection $items, + public readonly ?string $email = null, public readonly ?string $metadata = null, public readonly float $weight = 0.0, public readonly ?string $shippingMethod = null, diff --git a/src/Kanvas/Auth/Services/ForgotPassword.php b/src/Kanvas/Auth/Services/ForgotPassword.php index 97d70790b..cf26710e3 100644 --- a/src/Kanvas/Auth/Services/ForgotPassword.php +++ b/src/Kanvas/Auth/Services/ForgotPassword.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Kanvas\Apps\Models\Apps; use Kanvas\Enums\AppEnums; +use Kanvas\Exceptions\ModelNotFoundException as ExceptionsModelNotFoundException; use Kanvas\Notifications\Templates\ResetPassword; use Kanvas\Users\Models\Users; use Kanvas\Users\Models\UsersAssociatedApps; @@ -48,12 +49,16 @@ public function forgot(string $email): Users */ public function reset(string $newPassword, string $hashKey): bool { - $recoverUser = UsersAssociatedApps::fromApp($this->app) - ->notDeleted() - ->where([ - 'companies_id' => AppEnums::GLOBAL_COMPANY_ID->getValue(), - 'user_activation_forgot' => $hashKey, - ])->firstOrFail(); + try { + $recoverUser = UsersAssociatedApps::fromApp($this->app) + ->notDeleted() + ->where([ + 'companies_id' => AppEnums::GLOBAL_COMPANY_ID->getValue(), + 'user_activation_forgot' => $hashKey, + ])->firstOrFail(); + } catch (ModelNotFoundException $e) { + throw new ExceptionsModelNotFoundException('Password reset link has expired, request a new link.'); + } return $recoverUser->user()->firstOrFail()->resetPassword($newPassword, $this->app); }