Skip to content

Commit f6adf2a

Browse files
committed
bug fix: change password when remote access enabled
1 parent 2abb1f8 commit f6adf2a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

databases/databaseManager.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,19 @@ def changePassword(self, userID = None, data = None):
195195
db = Databases.objects.filter(dbUser=userName)
196196

197197
admin = Administrator.objects.get(pk=userID)
198+
198199
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
199200
pass
200201
else:
201202
return ACLManager.loadErrorJson()
202203

204+
try:
205+
meta = DBMeta.objects.get(database=db[0], key=DatabaseManager.REMOTE_ACCESS)
206+
host = json.loads(meta.value)['remoteIP']
207+
except:
208+
host = None
203209

204-
res = mysqlUtilities.changePassword(userName, dbPassword)
210+
res = mysqlUtilities.changePassword(userName, dbPassword, None, host)
205211

206212
if res == 0:
207213
data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."}

plogical/mysqlUtilities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def fetchStructure(name):
767767
return 0
768768

769769
@staticmethod
770-
def changePassword(userName, dbPassword, encrypt = None):
770+
def changePassword(userName, dbPassword, encrypt = None, host = None):
771771
try:
772772

773773
connection, cursor = mysqlUtilities.setupConnection()
@@ -776,6 +776,9 @@ def changePassword(userName, dbPassword, encrypt = None):
776776
return 0
777777
cursor.execute("use mysql")
778778

779+
if host != None:
780+
mysqlUtilities.LOCALHOST = host
781+
779782
if encrypt == None:
780783
try:
781784
dbuser = DBUsers.objects.get(user=userName)

0 commit comments

Comments
 (0)