-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
159 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
<?php namespace App\Http\Controllers; | ||
<?php | ||
|
||
use Illuminate\Foundation\Bus\DispatchesCommands; | ||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Foundation\Bus\DispatchesJobs; | ||
use Illuminate\Routing\Controller as BaseController; | ||
use Illuminate\Foundation\Validation\ValidatesRequests; | ||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | ||
|
||
abstract class Controller extends BaseController { | ||
|
||
use DispatchesCommands, ValidatesRequests; | ||
|
||
abstract class Controller extends BaseController | ||
{ | ||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\Post; | ||
use App\Models\User; | ||
|
||
class PostPolicy | ||
{ | ||
/** | ||
* Grant all abilities to administrator. | ||
* | ||
* @param \App\Models\User $user | ||
* @param string $ability | ||
* @return bool | ||
*/ | ||
public function before(User $user, $ability) | ||
{ | ||
if ($user->isAdmin()) { | ||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* Determine if the given post can be changed by the user. | ||
* | ||
* @param \App\Models\User $user | ||
* @param \App\Models\Post $post | ||
* @return bool | ||
*/ | ||
public function change(User $user, Post $post) | ||
{ | ||
return $user->id === $post->user_id; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Illuminate\Contracts\Auth\Access\Gate as GateContract; | ||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | ||
|
||
use App\Models\Post; | ||
use App\Policies\PostPolicy; | ||
|
||
class AuthServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The policy mappings for the application. | ||
* | ||
* @var array | ||
*/ | ||
protected $policies = [ | ||
Post::class => PostPolicy::class, | ||
]; | ||
|
||
/** | ||
* Register any application authentication / authorization services. | ||
* | ||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate | ||
* @return void | ||
*/ | ||
public function boot(GateContract $gate) | ||
{ | ||
parent::registerPolicies($gate); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<link href='http://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'> | ||
|
||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
color: #B0BEC5; | ||
display: table; | ||
font-weight: 100; | ||
font-family: 'Lato'; | ||
} | ||
.container { | ||
text-align: center; | ||
display: table-cell; | ||
vertical-align: middle; | ||
} | ||
.content { | ||
text-align: center; | ||
display: inline-block; | ||
} | ||
.title { | ||
font-size: 72px; | ||
margin-bottom: 40px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="content"> | ||
<div class="title">This action is unauthorized.</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |