SinglePageController.php 2.4 KB

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