MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / index

Function index

web/pgadmin/browser/__init__.py:401–459  ·  view source on GitHub ↗

Render and process the main browser window.

()

Source from the content-addressed store, hash-verified

399@pgCSRFProtect.exempt
400@pga_login_required
401def index():
402 """Render and process the main browser window."""
403
404 # Check the browser is a supported version
405 # NOTE: If the checks here are updated, make sure the supported versions
406 # at https://www.pgadmin.org/faq/#11 are updated to match!
407 if config.CHECK_SUPPORTED_BROWSER:
408 browser_name, browser_known, version = _get_supported_browser()
409
410 if browser_name is not None:
411 msg = render_template(
412 MODULE_NAME + "/browser.html",
413 version=version,
414 browser=browser_name,
415 known=browser_known
416 )
417
418 flash(msg, MessageType.WARNING)
419
420 session['allow_save_password'] = True
421
422 if config.SERVER_MODE and not config.MASTER_PASSWORD_REQUIRED and \
423 'pass_enc_key' in session:
424 session['allow_save_password'] = False
425
426 # Set the language cookie after login, so next time the user will have that
427 # same option at the login time.
428 misc_preference = Preferences.module('misc')
429 user_languages = misc_preference.preference(
430 'user_language'
431 )
432 language = 'en'
433 if user_languages:
434 language = user_languages.get() or 'en'
435
436 # Get the theme preference
437 user_theme = misc_preference.preference('theme')
438 theme = user_theme.get() or 'light' if user_theme else 'light'
439
440 domain = dict()
441 if config.COOKIE_DEFAULT_DOMAIN and\
442 config.COOKIE_DEFAULT_DOMAIN != 'localhost':
443 domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
444
445 response = Response(render_template(
446 MODULE_NAME + "/index.html",
447 username=current_user.username,
448 theme=theme,
449 _=gettext
450 ))
451
452 response.set_cookie("PGADMIN_LANGUAGE", value=language,
453 path=config.SESSION_COOKIE_PATH,
454 secure=config.SESSION_COOKIE_SECURE,
455 httponly=config.SESSION_COOKIE_HTTPONLY,
456 samesite=config.SESSION_COOKIE_SAMESITE,
457 **domain)
458

Callers

nothing calls this directly

Calls 5

_get_supported_browserFunction · 0.85
moduleMethod · 0.80
preferenceMethod · 0.80
set_cookieMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected