2016-09-01 16:23:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2016-09-11 07:19:11 +01:00
|
|
|
use App\User;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Http\Request;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Support\Facades\Artisan;
|
2016-09-11 07:19:11 +01:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2016-09-01 16:23:39 +01:00
|
|
|
|
|
|
|
class Controller extends BaseController
|
|
|
|
{
|
|
|
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
2016-09-11 07:19:11 +01:00
|
|
|
|
2017-03-21 21:48:55 +00:00
|
|
|
protected function authorizeAccessToAdminPanel()
|
|
|
|
{
|
|
|
|
// A user can access the admin panel if they are either an administrator, or are allowed to create albums
|
|
|
|
// Further checks within the admin panel determine what a user can do within the panel
|
|
|
|
if (!Auth::user()->can('admin-access') && !Auth::user()->can('admin-create-albums'))
|
|
|
|
{
|
|
|
|
App::abort(403);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-11 07:19:11 +01:00
|
|
|
/**
|
|
|
|
* Gets either the authenticated user, or a user object representing the anonymous user.
|
|
|
|
* @return User
|
|
|
|
*/
|
|
|
|
protected function getUser()
|
|
|
|
{
|
|
|
|
$user = Auth::user();
|
|
|
|
return (is_null($user)
|
|
|
|
? User::anonymous()
|
|
|
|
: $user);
|
|
|
|
}
|
2016-09-01 16:23:39 +01:00
|
|
|
}
|