2020-04-10 20:32:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2021-11-23 01:02:18 +01:00
|
|
|
use App\Setting\GeneralSettings;
|
2021-10-30 00:49:36 +02:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
2020-04-10 20:32:12 +02:00
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
2021-11-23 01:02:18 +01:00
|
|
|
use Illuminate\Support\Facades\Event;
|
2021-10-30 00:49:36 +02:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2021-11-23 01:02:18 +01:00
|
|
|
use Zoomyboy\LaravelNami\Authentication\NamiGuard;
|
2020-04-10 20:32:12 +02:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
JsonResource::withoutWrapping();
|
2020-06-02 23:45:25 +02:00
|
|
|
|
|
|
|
\Inertia::share('search', request()->query('search', ''));
|
2021-10-30 00:49:36 +02:00
|
|
|
|
|
|
|
RedirectResponse::macro('success', function($flash) {
|
|
|
|
session()->flash('flash', ['success' => $flash]);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
});
|
2020-04-10 20:32:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2021-11-23 01:02:18 +01:00
|
|
|
NamiGuard::beforeLogin(function(array $credentials) {
|
|
|
|
return in_array($credentials['mglnr'], app(GeneralSettings::class)->allowed_nami_accounts)
|
|
|
|
? null
|
|
|
|
: false;
|
|
|
|
});
|
2020-04-10 20:32:12 +02:00
|
|
|
}
|
|
|
|
}
|