4b8f2a63d8
11. Continue statt Review Dataset (im Step 3) 12. keywords auf default 'uncontrolled' einfrieren 14. Lizenzen mit Links versehen 19. Timezone: 'timezone' => 'Europe/Vienna' 20. angefangen mit RDR -> TETHYS Unbenennungen 21. translated validation ausgebessert 22. dataset als Typescript Instanz
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Http\Middleware;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Closure;
|
|
|
|
class PermissionMiddleware
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next, $permission)
|
|
{
|
|
if (Auth::guest()) {
|
|
if ($request->ajax()) {
|
|
return response('Unauthorized.', 401);
|
|
} else {
|
|
return redirect()->guest('/login');
|
|
}
|
|
}
|
|
|
|
//if (! $request->user()->hasRole($role))
|
|
//{
|
|
// abort(401);
|
|
//}
|
|
foreach ($request->user()->roles()->get() as $role) {
|
|
if ($role->hasPermissionTo($permission)) {
|
|
return $next($request);
|
|
}
|
|
//break(1);
|
|
}
|
|
|
|
//if (! $request->user()->can($permission))
|
|
//{
|
|
// abort(401);
|
|
//}
|
|
// return abort(403);
|
|
throw new \Illuminate\Auth\Access\AuthorizationException('This action is unauthorized.');
|
|
}
|
|
}
|