Parcourir la source

fix: altera type para user_type, seguindo a nova conversao

ebagabee il y a 1 mois
Parent
commit
486591ae01

+ 2 - 3
app/Http/Controllers/UserTypePermissionController.php

@@ -11,8 +11,7 @@ class UserTypePermissionController extends Controller
 {
     public function __construct(
         protected UserTypePermissionService $userTypePermissionService,
-    ) {
-    }
+    ) {}
 
     public function allGuestPermissions(): JsonResponse
     {
@@ -23,7 +22,7 @@ public function allGuestPermissions(): JsonResponse
     public function allPermissionsByUserType(): JsonResponse
     {
         $user = Auth::user();
-        $userTypePermission = $this->userTypePermissionService->allPermissionsByUserType($user->type);
+        $userTypePermission = $this->userTypePermissionService->allPermissionsByUserType($user->user_type);
         return $this->successResponse(payload: UserTypePermissionResource::collection($userTypePermission));
     }
 }

+ 1 - 1
app/Models/User.php

@@ -66,7 +66,7 @@ protected function casts(): array
         return [
             "email_verified_at" => "datetime",
             "password" => "hashed",
-            "type" => UserTypeEnum::class,
+            "user_type" => UserTypeEnum::class,
             "language" => LanguageEnum::class,
         ];
     }

+ 1 - 1
app/Services/AuthService.php

@@ -22,7 +22,7 @@ public function login(string $email, string $password, string $origem): ?array
         $user = User::where("email", $email)->first();
 
         if ($origem === 'admin') {
-            if ($user->user_type !== UserTypeEnum::ADMIN) {
+            if ($user->user_type !== UserTypeEnum::ADMIN->value) {
                 throw new Exception('credenciais invalidas para acesso de franqueadora');
             }
         }