浏览代码

Disallow client single if shadow_pro_id != NULL

Vijayakrishnan 3 年之前
父节点
当前提交
a3b2930117
共有 3 个文件被更改,包括 29 次插入1 次删除
  1. 1 0
      app/Http/Kernel.php
  2. 27 0
      app/Http/Middleware/EnsureClientIsNotShadowOfPro.php
  3. 1 1
      routes/web.php

+ 1 - 0
app/Http/Kernel.php

@@ -67,5 +67,6 @@ class Kernel extends HttpKernel
         'pro.auth.redirect' => \App\Http\Middleware\RedirectAuthenticatedPro::class,
         'pro.auth.admin' => \App\Http\Middleware\EnsureAdminPro::class,
         'pro.auth.can-access-patient' => \App\Http\Middleware\EnsureProCanAccessPatient::class,
+        'client.not-shadow-of-pro' => \App\Http\Middleware\EnsureClientIsNotShadowOfPro::class,
     ];
 }

+ 27 - 0
app/Http/Middleware/EnsureClientIsNotShadowOfPro.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Models\AppSession;
+use Closure;
+
+class EnsureClientIsNotShadowOfPro
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        $patient = \request()->route('patient');
+        if(!!$patient) {
+            if(!!$patient->shadow_pro_id) {
+                abort(403);
+            }
+        }
+        return $next($request);
+    }
+}

+ 1 - 1
routes/web.php

@@ -357,7 +357,7 @@ Route::middleware('pro.auth')->group(function () {
 
     Route::name('patients.view.')->prefix('patients/view/{patient}')->group(function () {
 
-        Route::middleware('pro.auth.can-access-patient')->group(function () {
+        Route::middleware(['pro.auth.can-access-patient', 'client.not-shadow-of-pro'])->group(function () {
 
             Route::get('', 'PatientController@dashboard')->name('dashboard');
             Route::get('canvas-migrate', 'PatientController@canvasMigrate')->name('migrate-canvas');