From 231b65ff7a4132e7fb248959d2abe1be02184836 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 2 Jul 2025 17:24:19 +0530 Subject: [PATCH] Added mpdf temp storage code --- app/Http/Controllers/PalletController.php | 2 +- app/Http/Controllers/UserController.php | 115 ++++++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/UserController.php diff --git a/app/Http/Controllers/PalletController.php b/app/Http/Controllers/PalletController.php index e4f82ec69..6f143bfab 100644 --- a/app/Http/Controllers/PalletController.php +++ b/app/Http/Controllers/PalletController.php @@ -57,7 +57,7 @@ class PalletController extends Controller 'margin_right' => 0, 'margin_top' => 0, 'margin_bottom' => 0, - //'tempDir' => '/var/www/storage/mpdf-tmp', + 'tempDir' => '/var/www/storage/mpdf-tmp', ]); $mpdf->WriteHTML($html); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 000000000..cd386f28a --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,115 @@ +header('Authorization'); + $header_user = $request->header('User-Name'); + $header_pass = $request->header('User-Pass'); + $expectedToken = $expectedUser . ':' . $expectedPw; + + if ("Bearer " . $expectedToken !== $header_auth) + { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Invalid authorization token!' + ], 403); + } + + if (!$header_user) + { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Invalid user name found!' + ], 400); + } + + $existUser = User::where('name', $header_user)->first(); + + if (!$existUser) + { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Unknown user name found!' + ], 400); + } + // if ($header_user !== $existUser->name) + // { + // return response()->json([ + // 'status_code' => 'ERROR', + // 'status_description' => 'Unknown user name found' + // ], 400); + // } + + // Retrieve the user by email + //$user = User::where('email', $email)->first(); + if (Hash::check($header_pass, $existUser->password)) { + return response()->json([ + 'roles' => $existUser->roles()->pluck('name')->toArray() + ], 200); + } else { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Password does not match!' + ], 400); + } + + // $machines = User::with('plant')->with('line')->orderBy('plant_id')->get(); + // $machinesData = $machines->map(function($machine) { + // return [ + // 'plant_code' => $machine->plant ? (String)$machine->plant->code : "", + // 'group_work_center' => $machine->line->group_work_center ?? "", + // 'work_center' => $machine->work_center ?? "", + // ]; + // }); + + // return response()->json([ + // 'machines' => $machinesData + // ]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +}