SinglePageController.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Events\ScanForNewReleaseCalled;
  4. use App\Facades\Settings;
  5. use Illuminate\Support\Facades\App;
  6. use Illuminate\Support\Facades\Auth;
  7. use Illuminate\Support\Facades\Vite;
  8. class SinglePageController extends Controller
  9. {
  10. /**
  11. * return the main view
  12. *
  13. * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
  14. */
  15. public function index()
  16. {
  17. event(new ScanForNewReleaseCalled);
  18. $settings = Settings::all()->toJson();
  19. $proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false;
  20. $proxyLogoutUrl = config('2fauth.config.proxyLogoutUrl') ? config('2fauth.config.proxyLogoutUrl') : false;
  21. $subdir = config('2fauth.config.appSubdirectory') ? '/' . config('2fauth.config.appSubdirectory') : '';
  22. $defaultPreferences = collect(config('2fauth.preferences')); /** @phpstan-ignore-line */
  23. $isDemoApp = config('2fauth.config.isDemoApp') ? 'true' : 'false';
  24. $isTestingApp = config('2fauth.config.isTestingApp') ? 'true' : 'false';
  25. $lang = App::getLocale();
  26. $locales = collect(config('2fauth.locales'))->toJson(); /** @phpstan-ignore-line */
  27. $openidAuth = config('services.openid.client_secret') ? true : false;
  28. $githubAuth = config('services.github.client_secret') ? true : false;
  29. $installDocUrl = config('2fauth.installDocUrl');
  30. $ssoDocUrl = config('2fauth.ssoDocUrl');
  31. $exportSchemaUrl = config('2fauth.exportSchemaUrl');
  32. $cspNonce = Vite::cspNonce();
  33. $isSecure = str_starts_with(config('app.url'), 'https');
  34. // if (Auth::user()->preferences)
  35. return view('landing')->with([
  36. 'appSettings' => $settings,
  37. 'appConfig' => collect([
  38. 'proxyAuth' => $proxyAuth,
  39. 'proxyLogoutUrl' => $proxyLogoutUrl,
  40. 'sso' => [
  41. 'openid' => $openidAuth,
  42. 'github' => $githubAuth,
  43. ],
  44. 'subdirectory' => $subdir,
  45. ])->toJson(),
  46. 'urls' => collect([
  47. 'installDocUrl' => $installDocUrl,
  48. 'ssoDocUrl' => $ssoDocUrl,
  49. 'exportSchemaUrl' => $exportSchemaUrl,
  50. ]),
  51. 'defaultPreferences' => $defaultPreferences,
  52. 'subdirectory' => $subdir,
  53. 'isDemoApp' => $isDemoApp,
  54. 'isTestingApp' => $isTestingApp,
  55. 'lang' => $lang,
  56. 'locales' => $locales,
  57. 'cspNonce' => $cspNonce,
  58. 'isSecure' => $isSecure,
  59. ]);
  60. }
  61. }