]> _ Git - odl.git/commitdiff
wip #4765
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 11 Oct 2021 11:54:59 +0000 (13:54 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 11 Oct 2021 11:54:59 +0000 (13:54 +0200)
app/Providers/AuthServiceProvider.php

index bcd9e06500c762e40ad6634aebb747d18e2cd45d..0e411ced5bc74f12f23c0f19393b25aa9db805bd 100644 (file)
@@ -26,5 +26,23 @@ class AuthServiceProvider extends CubistSocialiteAuthServiceProvider
     public function boot()
     {
         parent::boot();
+
+        $superadmins = ['vincent.vanwaelscappel@odile.space'];
+        $admins = ['jean-francois.legras@odile.space', 'christelle.perthus@odile.space'];
+        $viewers = [];
+
+        Gate::before(function ($user, $ability) use ($superadmins, $admins, $viewers) {
+            if (in_array($user->email, $superadmins)) {
+                return true;
+            }
+            if (in_array($user->email, $admins)) {
+                return $ability === 'admin' || $ability === 'view';
+            }
+            if (in_array($user->email, $viewers)) {
+                return $ability === 'view';
+            }
+            return null;
+        });
     }
+
 }