Viewing file: authCheck.php (891 B) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Http\Middleware; use Auth; use Closure; use Illuminate\Http\Request;
class authCheck { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param \String $authCheck
* @return mixed */ public function handle(Request $request, Closure $next, String $authCheck) { // if ($authCheck=='Admin' && auth()->admin()) { // # code... // } if ($authCheck=='r3' && auth()->user()->role !=='r3') { abort(403, 'Unauthorized action.'); } if ($authCheck=='r2' && auth()->user()->role !=='r2') { abort(403, 'Unauthorized action.'); } if ($authCheck=='r1' && auth()->user()->role !=='r1') { abort(403, 'Unauthorized action.'); } return $next($request); } }
|