bug fix: change password when remote access enabled

This commit is contained in:
Usman Nasir
2020-07-29 17:38:43 +05:00
parent 2abb1f84ed
commit f6adf2a617
2 changed files with 11 additions and 2 deletions

View File

@@ -195,13 +195,19 @@ class DatabaseManager:
db = Databases.objects.filter(dbUser=userName) db = Databases.objects.filter(dbUser=userName)
admin = Administrator.objects.get(pk=userID) admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1: if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
pass pass
else: else:
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try:
meta = DBMeta.objects.get(database=db[0], key=DatabaseManager.REMOTE_ACCESS)
host = json.loads(meta.value)['remoteIP']
except:
host = None
res = mysqlUtilities.changePassword(userName, dbPassword) res = mysqlUtilities.changePassword(userName, dbPassword, None, host)
if res == 0: if res == 0:
data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."} data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."}

View File

@@ -767,7 +767,7 @@ password=%s
return 0 return 0
@staticmethod @staticmethod
def changePassword(userName, dbPassword, encrypt = None): def changePassword(userName, dbPassword, encrypt = None, host = None):
try: try:
connection, cursor = mysqlUtilities.setupConnection() connection, cursor = mysqlUtilities.setupConnection()
@@ -776,6 +776,9 @@ password=%s
return 0 return 0
cursor.execute("use mysql") cursor.execute("use mysql")
if host != None:
mysqlUtilities.LOCALHOST = host
if encrypt == None: if encrypt == None:
try: try:
dbuser = DBUsers.objects.get(user=userName) dbuser = DBUsers.objects.get(user=userName)