-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added connected account policy and publishable auth service provider
- Loading branch information
Joel Butcher
committed
Mar 2, 2021
1 parent
ea12356
commit c5f4e08
Showing
4 changed files
with
141 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\ConnectedAccount; | ||
use App\Models\User; | ||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
|
||
class ConnectedAccountPolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
/** | ||
* Determine whether the user can view any models. | ||
* | ||
* @param \App\Models\User $user | ||
* @return mixed | ||
*/ | ||
public function viewAny(User $user) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Determine whether the user can view the model. | ||
* | ||
* @param \App\Models\User $user | ||
* @param \App\Models\ConnectedAccount $connectedAccount | ||
* @return mixed | ||
*/ | ||
public function view(User $user, ConnectedAccount $connectedAccount) | ||
{ | ||
return $user->ownsConnectedAccount($connectedAccount); | ||
} | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
* | ||
* @param \App\Models\User $user | ||
* @return mixed | ||
*/ | ||
public function create(User $user) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
* | ||
* @param \App\Models\User $user | ||
* @param \App\Models\ConnectedAccount $connectedAccount | ||
* @return mixed | ||
*/ | ||
public function update(User $user, ConnectedAccount $connectedAccount) | ||
{ | ||
return $user->ownsConnectedAccount($connectedAccount); | ||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
* | ||
* @param \App\Models\User $user | ||
* @param \App\Models\ConnectedAccount $connectedAccount | ||
* @return mixed | ||
*/ | ||
public function delete(User $user, ConnectedAccount $connectedAccount) | ||
{ | ||
return $user->ownsConnectedAccount($connectedAccount); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use App\Models\ConnectedAccount; | ||
use App\Policies\ConnectedAccountPolicy; | ||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | ||
|
||
class AuthServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The policy mappings for the application. | ||
* | ||
* @var array | ||
*/ | ||
protected $policies = [ | ||
ConnectedAccount::class => ConnectedAccountPolicy::class, | ||
]; | ||
|
||
/** | ||
* Register any authentication / authorization services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->registerPolicies(); | ||
|
||
// | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use App\Models\ConnectedAccount; | ||
use App\Models\Team; | ||
use App\Policies\ConnectedAccountPolicy; | ||
use App\Policies\TeamPolicy; | ||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | ||
|
||
class AuthServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The policy mappings for the application. | ||
* | ||
* @var array | ||
*/ | ||
protected $policies = [ | ||
Team::class => TeamPolicy::class, | ||
ConnectedAccount::class => ConnectedAccountPolicy::class, | ||
]; | ||
|
||
/** | ||
* Register any authentication / authorization services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->registerPolicies(); | ||
|
||
// | ||
} | ||
} |