From 5dcd85f0d9cfa53ff8bb839937310e33fc72482b Mon Sep 17 00:00:00 2001 From: sayliraut Date: Tue, 6 Aug 2024 17:15:55 +0530 Subject: [PATCH] changes --- .../APIs/RestaurantApi/RestAuthApiController.php | 15 +++++++++------ .../RestaurantService/RestAuthApiService.php | 16 ++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/APIs/RestaurantApi/RestAuthApiController.php b/app/Http/Controllers/APIs/RestaurantApi/RestAuthApiController.php index 3e40e96..32ec481 100644 --- a/app/Http/Controllers/APIs/RestaurantApi/RestAuthApiController.php +++ b/app/Http/Controllers/APIs/RestaurantApi/RestAuthApiController.php @@ -126,12 +126,12 @@ class RestAuthApiController extends Controller 'required', 'string', 'email', - // function ($attribute, $value, $fail) { - // $existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 4)->whereNull('deleted_at')->exists(); - // if (!$existingUser) { - // $fail('Entered e-mail address is not in our system.'); - // } - // }, + function ($attribute, $value, $fail) { + $existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 4)->whereNull('deleted_at')->exists(); + if (!$existingUser) { + $fail('The selected email address is invalid.'); + } + }, ], ]); @@ -246,4 +246,7 @@ class RestAuthApiController extends Controller return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500); } } + + + } diff --git a/app/Services/APIs/RestaurantService/RestAuthApiService.php b/app/Services/APIs/RestaurantService/RestAuthApiService.php index c40a6e9..dbef22b 100644 --- a/app/Services/APIs/RestaurantService/RestAuthApiService.php +++ b/app/Services/APIs/RestaurantService/RestAuthApiService.php @@ -160,19 +160,15 @@ class RestAuthApiService { try { DB::beginTransaction(); - $user = IamPrincipal::where('email_address', $request->email_address) ->where('principal_type_xid', 4) ->whereNull('deleted_at') - ->exists(); - - - if (!$user) { - return jsonResponseWithDataErrorMessageApi(__('EmailNotExist'), ('Entered e-mail address is not in our system. Register for an account here.')); - - } - - + ->first(); + //use this for both customer and restaurant just change principal_type_xid 4 + if ($user == null) { + Log::error('Email not exist'); + return jsonResponseWithErrorMessageApi(__('auth.incorrect_email'), 403); + } // Define the generateOTP function $otp = $this->generateOTP();