mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Replace Flask-BabelEx with Flask-Babel. Fixes #6088
2) Upgrade Flask to version 2. Fixes #7010
This commit is contained in:
@@ -209,8 +209,11 @@ def upgrade():
|
||||
os.urandom(32)).decode()
|
||||
db.engine.execute(sql)
|
||||
|
||||
sql = "INSERT INTO keys (name, value) VALUES ('SECRET_KEY', '%s')" % base64.urlsafe_b64encode(
|
||||
os.urandom(32)).decode()
|
||||
if hasattr(config, 'SECRET_KEY'):
|
||||
sql = "INSERT INTO keys (name, value) VALUES ('SECRET_KEY', '%s')" % config.SECRET_KEY
|
||||
else:
|
||||
sql = "INSERT INTO keys (name, value) VALUES ('SECRET_KEY', '%s')" % base64.urlsafe_b64encode(
|
||||
os.urandom(32)).decode()
|
||||
db.engine.execute(sql)
|
||||
|
||||
# If SECURITY_PASSWORD_SALT is not in the config, but we're upgrading, then it must (unless the
|
||||
|
||||
@@ -22,7 +22,7 @@ import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from flask import current_app
|
||||
from flask_security import Security, SQLAlchemyUserDatastore
|
||||
from flask_security.utils import encrypt_password
|
||||
from flask_security.utils import hash_password
|
||||
from pgadmin.model import db, User, Role
|
||||
from pgadmin.setup import get_version
|
||||
from pgadmin.setup import user_info
|
||||
@@ -116,14 +116,24 @@ VALUES(1, 1, 'Servers')
|
||||
os.urandom(32)
|
||||
).decode()
|
||||
)
|
||||
|
||||
secret_key = getattr(
|
||||
config, 'SECRET_KEY', base64.urlsafe_b64encode(
|
||||
os.urandom(32)
|
||||
).decode()
|
||||
)
|
||||
if current_app.extensions.get('security') is None:
|
||||
current_app.config['SECURITY_PASSWORD_SALT'] = current_salt
|
||||
current_app.config['SECRET_KEY'] = secret_key
|
||||
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
|
||||
Security(current_app, user_datastore, register_blueprint=False)
|
||||
else:
|
||||
current_app.config['SECURITY_PASSWORD_SALT'] = current_salt
|
||||
current_app.config['SECRET_KEY'] = secret_key
|
||||
|
||||
setattr(config, 'SECURITY_PASSWORD_SALT', current_salt)
|
||||
password = encrypt_password(password)
|
||||
setattr(config, 'SECRET_KEY', secret_key)
|
||||
password = hash_password(password)
|
||||
|
||||
db.engine.execute("""
|
||||
INSERT INTO "user"
|
||||
|
||||
Reference in New Issue
Block a user