2024-09-27 20:41:36 -04:00
|
|
|
<?php
|
|
|
|
|
2025-01-30 00:23:55 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-09-27 20:41:36 -04:00
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Models\OAuthConnection;
|
|
|
|
use App\Models\User;
|
|
|
|
|
|
|
|
class OAuthConnectionPolicy
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view the model.
|
|
|
|
*/
|
|
|
|
public function view(User $user, OAuthConnection $oauthConnection): bool
|
|
|
|
{
|
|
|
|
return $user->id === $oauthConnection->user_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can delete the model.
|
|
|
|
*/
|
|
|
|
public function delete(User $user, OAuthConnection $oauthConnection): bool
|
|
|
|
{
|
|
|
|
return $user->id === $oauthConnection->user_id && $user->password !== null;
|
|
|
|
}
|
|
|
|
}
|