Fixing routing issues
This commit is contained in:
@@ -961,7 +961,7 @@ class TelemetryController extends Controller
|
||||
|
||||
// Retrieve devices of user
|
||||
$assetDeviceListing = UserAssetLink::with('asset.devices')
|
||||
->where('user_id', $token['sub'])
|
||||
->where(['user_id' => $token['sub'], 'active' => 1])
|
||||
->get();
|
||||
|
||||
$formattedData = $assetDeviceListing->map(function ($link) {
|
||||
|
||||
@@ -92,7 +92,7 @@ class AdminService
|
||||
// throw new Exception('Failed to create asset: ' . $response->body());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// public function createAsset(array $data)
|
||||
// {
|
||||
// $token = $this->getToken();
|
||||
@@ -150,7 +150,7 @@ class AdminService
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
])->withBody(json_encode($payload), 'application/json')
|
||||
->post("{$this->baseUrl}/api/asset");
|
||||
->post("{$this->baseUrl}api/asset");
|
||||
|
||||
if ($response->successful()) {
|
||||
return $response->json();
|
||||
@@ -206,7 +206,7 @@ class AdminService
|
||||
|
||||
|
||||
|
||||
$url = "{$this->baseUrl}/api/customer";
|
||||
$url = "{$this->baseUrl}api/customer";
|
||||
$method = 'post';
|
||||
// Send request
|
||||
$response = Http::withHeaders([
|
||||
@@ -267,7 +267,7 @@ class AdminService
|
||||
'Content-Type' => 'application/json',
|
||||
])
|
||||
->timeout(30)
|
||||
->post("{$this->baseUrl}/api/user", $payload);
|
||||
->post("{$this->baseUrl}api/user", $payload);
|
||||
|
||||
if ($response->successful()) {
|
||||
return $response->json();
|
||||
@@ -310,7 +310,7 @@ class AdminService
|
||||
'Authorization' => "Bearer $token",
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
])->delete("{$this->baseUrl}/api/asset/{$assetId}");
|
||||
])->delete("{$this->baseUrl}api/asset/{$assetId}");
|
||||
|
||||
Log::info('Asset Deletion Response: ' . $response);
|
||||
|
||||
@@ -360,7 +360,7 @@ class AdminService
|
||||
'Authorization' => "Bearer $token",
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
])->post("{$this->baseUrl}/api/customer/{$customerId}/asset/{$assetId}");
|
||||
])->post("{$this->baseUrl}api/customer/{$customerId}/asset/{$assetId}");
|
||||
|
||||
// Log the response for debugging purposes
|
||||
Log::info('Asset Assignment Response: ' . $response->body());
|
||||
@@ -381,7 +381,7 @@ class AdminService
|
||||
$token = $this->getToken();
|
||||
|
||||
|
||||
$url = "{$this->baseUrl}/api/customer/{$data['customerId']}";
|
||||
$url = "{$this->baseUrl}api/customer/{$data['customerId']}";
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => "Bearer $token",
|
||||
@@ -413,9 +413,10 @@ class AdminService
|
||||
$token = $this->getToken();
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => "Bearer $token",
|
||||
'X-Authorization' => "Bearer $token",
|
||||
'accept' => 'application/json',
|
||||
])->get("{$this->baseUrl}/api/users?pageSize=100&page=0");
|
||||
'Content-Type' => 'application/json',
|
||||
])->get("{$this->baseUrl}api/users?pageSize=100&page=0");
|
||||
|
||||
if ($response->successful()) {
|
||||
return $response->json();
|
||||
@@ -432,7 +433,7 @@ class AdminService
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => "Bearer $token",
|
||||
'accept' => 'application/json',
|
||||
])->delete("{$this->baseUrl}/api/user/{$userId}");
|
||||
])->delete("{$this->baseUrl}api/user/{$userId}");
|
||||
|
||||
if ($response->failed()) {
|
||||
Log::error('ThingsBoard deletion failed - Status: ' . $response->status() . ' - Body: ' . $response->body());
|
||||
@@ -499,7 +500,7 @@ class AdminService
|
||||
$searchResponse = Http::withHeaders([
|
||||
'Authorization' => "Bearer $token",
|
||||
'accept' => 'application/json'
|
||||
])->get("{$this->baseUrl}/api/users?pageSize=1&page=0&textSearch={$user->email}");
|
||||
])->get("{$this->baseUrl}api/users?pageSize=1&page=0&textSearch={$user->email}");
|
||||
|
||||
if ($searchResponse->successful() && !empty($searchResponse['data'])) {
|
||||
$tbUser = $searchResponse['data'][0];
|
||||
@@ -509,7 +510,7 @@ class AdminService
|
||||
Http::withHeaders([
|
||||
'Authorization' => "Bearer $token",
|
||||
'Content-Type' => 'application/json'
|
||||
])->post("{$this->baseUrl}/api/user", [
|
||||
])->post("{$this->baseUrl}api/user", [
|
||||
'id' => ['id' => $tbUserId],
|
||||
// 'email' => $dummyEmail,
|
||||
'authority' => $tbUser['authority'],
|
||||
@@ -530,7 +531,7 @@ class AdminService
|
||||
// 'email' => $dummyEmail
|
||||
];
|
||||
|
||||
$activationUrl = "{$this->baseUrl}/api/noauth/activate";
|
||||
$activationUrl = "{$this->baseUrl}api/noauth/activate";
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
@@ -608,7 +609,7 @@ class AdminService
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => "Bearer $token",
|
||||
'accept' => 'application/json',
|
||||
])->get("{$this->baseUrl}/api/users?pageSize=100&page=0");
|
||||
])->get("{$this->baseUrl}api/users?pageSize=100&page=0");
|
||||
|
||||
if ($response->successful()) {
|
||||
return $response->json();
|
||||
|
||||
Reference in New Issue
Block a user