mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Merged adjustanct 'if' statements when allowed.
Also - removed the unused variables.
This commit is contained in:
parent
6c5883bce0
commit
a930c6617b
@ -117,13 +117,12 @@ else:
|
|||||||
app.debug = False
|
app.debug = False
|
||||||
|
|
||||||
# respond to JS
|
# respond to JS
|
||||||
if config.DEBUG:
|
if config.DEBUG and javascriptBundler.report() == JsState.NONE:
|
||||||
if javascriptBundler.report() == JsState.NONE:
|
app.logger.error(
|
||||||
app.logger.error("Unable to generate javascript")
|
"Unable to generate javascript.\n"
|
||||||
app.logger.error(
|
"To run the app ensure that yarn install command runs successfully"
|
||||||
"To run the app ensure that yarn install command runs successfully"
|
)
|
||||||
)
|
raise Exception("No generated javascript, aborting")
|
||||||
raise Exception("No generated javascript, aborting")
|
|
||||||
|
|
||||||
# Start the web server. The port number should have already been set by the
|
# Start the web server. The port number should have already been set by the
|
||||||
# runtime if we're running in desktop mode, otherwise we'll just use the
|
# runtime if we're running in desktop mode, otherwise we'll just use the
|
||||||
|
@ -472,7 +472,7 @@ def create_app(app_name=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
|
proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
proc_arch64 = None
|
proc_arch64 = None
|
||||||
|
|
||||||
if proc_arch == 'x86' and not proc_arch64:
|
if proc_arch == 'x86' and not proc_arch64:
|
||||||
@ -486,7 +486,7 @@ def create_app(app_name=None):
|
|||||||
try:
|
try:
|
||||||
root_key = winreg.OpenKey(
|
root_key = winreg.OpenKey(
|
||||||
winreg.HKEY_LOCAL_MACHINE,
|
winreg.HKEY_LOCAL_MACHINE,
|
||||||
"SOFTWARE\\" + server_type + "\Services", 0,
|
"SOFTWARE\\" + server_type + "\\Services", 0,
|
||||||
winreg.KEY_READ | arch_key
|
winreg.KEY_READ | arch_key
|
||||||
)
|
)
|
||||||
for i in xrange(0, winreg.QueryInfoKey(root_key)[0]):
|
for i in xrange(0, winreg.QueryInfoKey(root_key)[0]):
|
||||||
@ -518,7 +518,7 @@ def create_app(app_name=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
inst_key.Close()
|
inst_key.Close()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# We use the postgres-winreg.ini file on non-Windows
|
# We use the postgres-winreg.ini file on non-Windows
|
||||||
@ -566,7 +566,7 @@ def create_app(app_name=None):
|
|||||||
svr_superuser, svr_port, svr_discovery_id,
|
svr_superuser, svr_port, svr_discovery_id,
|
||||||
svr_comment)
|
svr_comment)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@user_logged_in.connect_via(app)
|
@user_logged_in.connect_via(app)
|
||||||
@ -618,12 +618,13 @@ def create_app(app_name=None):
|
|||||||
|
|
||||||
# Check the auth key is valid, if it's set, and we're not in server
|
# Check the auth key is valid, if it's set, and we're not in server
|
||||||
# mode, and it's not a help file request.
|
# mode, and it's not a help file request.
|
||||||
if not config.SERVER_MODE and app.PGADMIN_INT_KEY != '':
|
if not config.SERVER_MODE and app.PGADMIN_INT_KEY != '' and ((
|
||||||
if (('key' not in request.args or
|
'key' not in request.args or
|
||||||
request.args['key'] != app.PGADMIN_INT_KEY) and
|
request.args['key'] != app.PGADMIN_INT_KEY) and
|
||||||
request.cookies.get('PGADMIN_INT_KEY') !=
|
request.cookies.get('PGADMIN_INT_KEY') != app.PGADMIN_INT_KEY and
|
||||||
app.PGADMIN_INT_KEY and request.endpoint != 'help.static'):
|
request.endpoint != 'help.static'
|
||||||
abort(401)
|
):
|
||||||
|
abort(401)
|
||||||
|
|
||||||
if not config.SERVER_MODE and not current_user.is_authenticated:
|
if not config.SERVER_MODE and not current_user.is_authenticated:
|
||||||
user = user_datastore.get_user(config.DESKTOP_USER)
|
user = user_datastore.get_user(config.DESKTOP_USER)
|
||||||
@ -642,11 +643,10 @@ def create_app(app_name=None):
|
|||||||
# if the server is restarted the in memory key will be lost
|
# if the server is restarted the in memory key will be lost
|
||||||
# but the user session may still be active. Logout the user
|
# but the user session may still be active. Logout the user
|
||||||
# to get the key again when login
|
# to get the key again when login
|
||||||
if config.SERVER_MODE and current_user.is_authenticated:
|
if config.SERVER_MODE and current_user.is_authenticated and \
|
||||||
if current_app.keyManager.get() is None and \
|
current_app.keyManager.get() is None and \
|
||||||
request.endpoint not in ('security.login',
|
request.endpoint not in ('security.login', 'security.logout'):
|
||||||
'security.logout'):
|
logout_user()
|
||||||
logout_user()
|
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def after_request(response):
|
def after_request(response):
|
||||||
|
Loading…
Reference in New Issue
Block a user