From d79dabbbaf9db76c7a5cf47fa57770712b684264 Mon Sep 17 00:00:00 2001 From: kshitige Date: Wed, 23 Apr 2025 16:44:25 +0530 Subject: [PATCH 1/2] school --- app/Http/Controllers/APIS/AdminApi/DeviceController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/APIS/AdminApi/DeviceController.php b/app/Http/Controllers/APIS/AdminApi/DeviceController.php index c32f32e..b4fc78d 100644 --- a/app/Http/Controllers/APIS/AdminApi/DeviceController.php +++ b/app/Http/Controllers/APIS/AdminApi/DeviceController.php @@ -180,7 +180,7 @@ class DeviceController extends Controller public function devicelistCustomer($customerId) - { + { try { $devices = Device::with('deviceProfile:id,name', 'customer:id,name') ->where('customer_id', $customerId) -- 2.34.1 From d07dc2fd6a1efa51be01b4e283622428286fafde Mon Sep 17 00:00:00 2001 From: kshitige Date: Wed, 23 Apr 2025 16:55:25 +0530 Subject: [PATCH 2/2] school --- app/Services/AdminService.php | 36 +++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/app/Services/AdminService.php b/app/Services/AdminService.php index 8ec4a60..84f448c 100644 --- a/app/Services/AdminService.php +++ b/app/Services/AdminService.php @@ -490,12 +490,42 @@ class AdminService } } + // public function activateUser(User $user, string $password, string $activateToken) + // { + // try { + // $payload = [ + // 'activateToken' => $activateToken, + // 'password' => $password + // ]; + + // $activationUrl = "{$this->baseUrl}/api/noauth/activate"; + + // $response = Http::withHeaders([ + // 'Content-Type' => 'application/json', + // ])->post($activationUrl, $payload); + + // if (!$response->successful()) { + // Log::error("Failed to activate user in ThingsBoard. Error: " . $response->body()); + // throw new \Exception('Failed to activate user: ' . $response->body()); + // } + + // Log::info("User activated successfully in ThingsBoard for User ID: {$user->id}"); + // } catch (\Exception $e) { + // Log::error("Error activating user in ThingsBoard for User ID: {$user->id}. Exception: " . $e->getMessage()); + // throw $e; + // } + // } + + public function activateUser(User $user, string $password, string $activateToken) { try { + $dummyEmail = 'dummy+' . $user->id . '@example.com'; // unique dummy email + $payload = [ 'activateToken' => $activateToken, - 'password' => $password + 'password' => $password, + 'email' => $dummyEmail // send dummy email to ThingsBoard ]; $activationUrl = "{$this->baseUrl}/api/noauth/activate"; @@ -509,7 +539,7 @@ class AdminService throw new \Exception('Failed to activate user: ' . $response->body()); } - Log::info("User activated successfully in ThingsBoard for User ID: {$user->id}"); + Log::info("User activated in ThingsBoard with dummy email: {$dummyEmail} for User ID: {$user->id}"); } catch (\Exception $e) { Log::error("Error activating user in ThingsBoard for User ID: {$user->id}. Exception: " . $e->getMessage()); throw $e; @@ -517,8 +547,6 @@ class AdminService } - - public function getUserByEmailThingsBoard(string $email) { Log::info("Fetching ThingsBoard ID by email: $email"); -- 2.34.1