mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-24 08:30:28 +00:00
update
This commit is contained in:
parent
5a9cd63159
commit
6b2263a8c9
3 changed files with 49 additions and 11 deletions
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Customer\App\Http\Middleware;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Illuminate\Auth\Middleware\Authenticate;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerAuthenticate extends Authenticate
|
||||
{
|
||||
/**
|
||||
* @param array<string> $guards
|
||||
*/
|
||||
protected function authenticate($request, array $guards): void
|
||||
{
|
||||
$guard = Filament::auth();
|
||||
|
||||
if (! $guard->check()) {
|
||||
$this->unauthenticated($request, $guards);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->auth->shouldUse(Filament::getAuthGuard());
|
||||
|
||||
// /** @var Model $user */
|
||||
// $user = $guard->user();
|
||||
//
|
||||
// $panel = Filament::getCurrentPanel();
|
||||
|
||||
}
|
||||
|
||||
protected function redirectTo($request): ?string
|
||||
{
|
||||
return Filament::getLoginUrl();
|
||||
}
|
||||
}
|
|
@ -75,7 +75,7 @@ class CustomerPanelProvider extends PanelProvider
|
|||
])
|
||||
->authGuard('web_customer')
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
CustomerAuthenticate::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,16 +37,16 @@ class HostingSubscriptionBackup extends Model
|
|||
'status' => BackupStatus::class,
|
||||
];
|
||||
|
||||
// protected static function booted(): void
|
||||
// {
|
||||
// static::addGlobalScope('customer', function (Builder $query) {
|
||||
// if (auth()->check() && auth()->guard()->name == 'web_customer') {
|
||||
// $query->whereHas('hostingSubscription', function ($query) {
|
||||
// $query->where('customer_id', auth()->user()->id);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope('customer', function (Builder $query) {
|
||||
if (auth()->check() && auth()->guard()->name == 'web_customer') {
|
||||
$query->whereHas('hostingSubscription', function ($query) {
|
||||
$query->where('customer_id', auth()->user()->id);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
|
Loading…
Reference in a new issue