HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //home/xedaptot/hi.naniguide.com/app/Providers/AuthServiceProvider.php
<?php

namespace App\Providers;

use App\Models\Setting;
use App\Models\Subscription;
use App\Policies\SubscriptionPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Blade;

class AuthServiceProvider extends ServiceProvider
{
    protected $policies = [
        Subscription::class => SubscriptionPolicy::class,
    ];

    public function boot(): void
    {
        $this->registerPolicies();

        Blade::if('admincan', function (string $ability): bool {
            $user = auth('admin')->user();
            if (!$user) {
                return false;
            }

            if (method_exists($user, 'isSuperAdmin') && $user->isSuperAdmin()) {
                return true;
            }

            return method_exists($user, 'hasAdminAbility')
                ? (bool) $user->hasAdminAbility($ability)
                : false;
        });

        Blade::if('customercan', function (string $ability): bool {
            $customer = auth('customer')->user();
            if (!$customer) {
                return false;
            }

            return method_exists($customer, 'groupAllows')
                ? (bool) $customer->groupAllows($ability)
                : false;
        });

        try {
            $enabled = Setting::get('google_enabled', false);
            $enabled = filter_var($enabled, FILTER_VALIDATE_BOOLEAN);

            if (!$enabled) {
                config([
                    'services.google.client_id' => null,
                    'services.google.client_secret' => null,
                    'services.google.redirect' => null,
                ]);
                return;
            }

            $clientId = Setting::get('google_client_id', config('services.google.client_id'));
            $clientSecret = Setting::get('google_client_secret', config('services.google.client_secret'));
            $redirectUri = Setting::get('google_redirect_uri', config('services.google.redirect'));

            if (is_string($clientId)) {
                $clientId = trim($clientId);
            }
            if (is_string($clientSecret)) {
                $clientSecret = trim($clientSecret);
            }
            if (is_string($redirectUri)) {
                $redirectUri = trim($redirectUri);
            }

            config([
                'services.google.client_id' => (is_string($clientId) && $clientId !== '') ? $clientId : config('services.google.client_id'),
                'services.google.client_secret' => (is_string($clientSecret) && $clientSecret !== '') ? $clientSecret : config('services.google.client_secret'),
                'services.google.redirect' => (is_string($redirectUri) && $redirectUri !== '') ? $redirectUri : config('services.google.redirect'),
            ]);
        } catch (\Throwable $e) {
            // Ignore settings failures during early bootstrap.
        }
    }
}