Applied manual JWT check and restored all driver fields68j2

This commit is contained in:
Hamza-Ayed
2026-04-25 15:07:51 +03:00
parent da590e7fc0
commit 61212b60af
5 changed files with 52 additions and 7 deletions

View File

@@ -170,6 +170,7 @@ class AuthController extends Controller
'driver_license_back' => 'required|url', 'driver_license_back' => 'required|url',
'car_license_front' => 'required|url', 'car_license_front' => 'required|url',
'car_license_back' => 'required|url', 'car_license_back' => 'required|url',
'national_number' => 'required|string',
]); ]);
$data = $request->all(); $data = $request->all();
@@ -396,7 +397,7 @@ class AuthController extends Controller
->select([ ->select([
'd.id', 'd.phone', 'd.email', 'd.gender', 'd.status', 'd.id', 'd.phone', 'd.email', 'd.gender', 'd.status',
'd.first_name', 'd.last_name', 'd.password', 'd.first_name', 'd.last_name', 'd.password',
'd.name_arabic', 'd.name_arabic', 'd.national_number',
'phone_verification.verified as is_verified', 'phone_verification.verified as is_verified',
'invites.isInstall', 'invites.isInstall',
'shamCash.is_claimed', 'shamCash.is_claimed',
@@ -418,7 +419,7 @@ class AuthController extends Controller
} }
// Decrypt necessary fields // Decrypt necessary fields
$fieldsToDecrypt = ['email', 'phone', 'first_name', 'last_name', 'gender', 'name_arabic']; $fieldsToDecrypt = ['email', 'phone', 'first_name', 'last_name', 'gender', 'name_arabic', 'national_number'];
foreach ($fieldsToDecrypt as $field) { foreach ($fieldsToDecrypt as $field) {
if (!empty($driver[$field])) { if (!empty($driver[$field])) {
$dec = $this->encryption->decrypt($driver[$field]); $dec = $this->encryption->decrypt($driver[$field]);
@@ -459,7 +460,7 @@ class AuthController extends Controller
->leftJoin('driverToken', 'driverToken.captain_id', '=', 'd.id') ->leftJoin('driverToken', 'driverToken.captain_id', '=', 'd.id')
->select([ ->select([
'd.id', 'd.phone', 'd.email', 'd.gender', 'd.status', 'd.id', 'd.phone', 'd.email', 'd.gender', 'd.status',
'd.first_name', 'd.last_name', 'd.name_arabic', 'd.first_name', 'd.last_name', 'd.name_arabic', 'd.national_number',
'd.birthdate', 'd.site', 'd.employmentType', 'd.maritalStatus', 'd.birthdate', 'd.site', 'd.employmentType', 'd.maritalStatus',
'd.accountBank', 'd.bankCode', 'd.accountBank', 'd.bankCode',
'phone_verification.is_verified', 'phone_verification.is_verified',
@@ -478,7 +479,7 @@ class AuthController extends Controller
$driver = (array) $row; $driver = (array) $row;
// Decrypt necessary fields // Decrypt necessary fields
$fieldsToDecrypt = ['email', 'phone', 'first_name', 'last_name', 'gender', 'name_arabic']; $fieldsToDecrypt = ['email', 'phone', 'first_name', 'last_name', 'gender', 'name_arabic', 'national_number'];
foreach ($fieldsToDecrypt as $field) { foreach ($fieldsToDecrypt as $field) {
if (!empty($driver[$field])) { if (!empty($driver[$field])) {
$dec = $this->encryption->decrypt($driver[$field]); $dec = $this->encryption->decrypt($driver[$field]);

View File

@@ -270,9 +270,10 @@ class MiscController extends Controller
'user_agent' => $request->userAgent(), 'user_agent' => $request->userAgent(),
]); ]);
$error = $request->input('error') ?? 'Error logged';
return response()->json([ return response()->json([
'status' => 'success', 'status' => 'success',
'message' => 'Error logged', 'message' => $error,
]); ]);
} }
} }

View File

@@ -176,4 +176,37 @@ class ProfileController extends Controller
return response()->json(['status' => 'success', 'message' => 'Sham Cash details updated']); return response()->json(['status' => 'success', 'message' => 'Sham Cash details updated']);
} }
/**
* POST /v2/profile/driver/car
*/
public function updateDriverCar(Request $request): JsonResponse
{
$id = $request->attributes->get('_jwt_user_id');
$car = CarRegistration::where('driverID', $id)->where('isDefault', 1)->first();
if (!$car) {
return response()->json(['status' => 'failure', 'message' => 'Car not found'], 404);
}
$fields = ['make', 'model', 'year', 'color', 'color_hex', 'expiration_date', 'vin', 'car_plate'];
$updates = [];
foreach ($fields as $f) {
if ($request->has($f)) {
$val = $request->input($f);
if (in_array($f, CarRegistration::ENCRYPTED_FIELDS)) {
$updates[$f] = $this->enc->encrypt($val);
} else {
$updates[$f] = $val;
}
}
}
if (!empty($updates)) {
$car->update($updates);
}
return response()->json(['status' => 'success', 'message' => 'Vehicle details updated']);
}
} }

View File

@@ -613,15 +613,24 @@ class RideController extends Controller
$query->forPassenger($userId); $query->forPassenger($userId);
} }
$rides = $query->orderBy('id', 'desc') $rides = $query->with('passenger')->orderBy('id', 'desc')
->skip(($page - 1) * $limit) ->skip(($page - 1) * $limit)
->take($limit) ->take($limit)
->get() ->get()
->map(function ($ride) { ->map(function ($ride) {
$ride->order_id = $ride->id; $ride->order_id = $ride->id;
$ride->start_name = "Pickup point"; // Simplified for now $ride->start_name = "Pickup point";
$ride->end_name = "Destination point"; $ride->end_name = "Destination point";
$ride->price = (string) number_format($ride->price, 0, '.', ''); $ride->price = (string) number_format($ride->price, 0, '.', '');
if ($ride->passenger) {
$p = $ride->passenger;
$fname = !empty($p->first_name) ? $this->encryption->decrypt($p->first_name) : '';
$lname = !empty($p->last_name) ? $this->encryption->decrypt($p->last_name) : '';
$ride->passenger_name = trim($fname . ' ' . $lname);
$ride->passenger_phone = !empty($p->phone) ? $this->encryption->decrypt($p->phone) : '';
}
return $ride; return $ride;
}); });

View File

@@ -112,6 +112,7 @@ Route::prefix('v2')->middleware(['hmac.auth', 'jwt.auth'])->group(function () {
Route::match(['post', 'put'], '/profile/passenger', [ProfileController::class, 'updatePassenger']); Route::match(['post', 'put'], '/profile/passenger', [ProfileController::class, 'updatePassenger']);
Route::match(['post', 'put'], '/profile/driver/email', [ProfileController::class, 'updateDriverEmail']); Route::match(['post', 'put'], '/profile/driver/email', [ProfileController::class, 'updateDriverEmail']);
Route::post('/profile/driver/shamcash', [ProfileController::class, 'updateShamCash']); Route::post('/profile/driver/shamcash', [ProfileController::class, 'updateShamCash']);
Route::match(['post', 'put'], '/profile/driver/car', [ProfileController::class, 'updateDriverCar']);
// ── Wallet ── // ── Wallet ──
// All wallet operations (balance, funds, transactions) are handled by the // All wallet operations (balance, funds, transactions) are handled by the