Add save password option in sever create mode. Fixes #1450

Do a little string/layout cleanup whilst passing.
This commit is contained in:
Harshal Dhumal
2016-08-03 15:55:45 +01:00
committed by Dave Page
parent 68497b00f6
commit dfceb63986
2 changed files with 26 additions and 11 deletions

View File

@@ -570,6 +570,8 @@ class ServerNode(PGChildNodeView):
)
)
server = None
try:
server = Server(
user_id=current_user.id,
@@ -596,8 +598,10 @@ class ServerNode(PGChildNodeView):
manager.update(server)
conn = manager.connection()
have_password = False
if 'password' in data and data["password"] != '':
# login with password
have_password = True
password = data['password']
password = encrypt(password, current_user.password)
else:
@@ -618,6 +622,10 @@ class ServerNode(PGChildNodeView):
errormsg=gettext("Unable to connect to server:\n\n%s" % errmsg)
)
else:
if 'save_password' in data and data['save_password'] and have_password:
setattr(server, 'password', password)
db.session.commit()
user = manager.user_info
connected = True
icon = "icon-pg"