User management.

This commit is contained in:
Harshal Dhumal
2016-06-06 13:34:08 +01:00
committed by Dave Page
parent 4398d1d869
commit e3ab4501d5
7 changed files with 1068 additions and 5 deletions
+21 -3
View File
@@ -69,12 +69,17 @@ account:\n""")
db.create_all()
user_datastore.create_role(
name='Administrators',
description='pgAdmin Administrators Role'
name='Administrator',
description='pgAdmin Administrator Role'
)
user_datastore.create_role(
name='User',
description='pgAdmin User Role'
)
user_datastore.create_user(email=email, password=password)
db.session.flush()
user_datastore.add_role_to_user(email, 'Administrators')
user_datastore.add_role_to_user(email, 'Administrator')
# Get the user's ID and create the default server group
user = User.query.filter_by(email=email).first()
@@ -249,6 +254,19 @@ CREATE TABLE process(
FOREIGN KEY(user_id) REFERENCES user (id)
)""")
if int(version.value) < 11:
db.engine.execute("""
UPDATE role
SET name = 'Administrator',
description = 'pgAdmin Administrator Role'
WHERE name = 'Administrators'
""")
db.engine.execute("""
INSERT INTO role ( name, description )
VALUES ('User', 'pgAdmin User Role')
""")
# Finally, update the schema version
version.value = config.SETTINGS_SCHEMA_VERSION
db.session.merge(version)