usmannasir 2025-08-02 09:42:18 +05:00
parent 1bca3e0f4d
commit 49635c415d
1 changed files with 6 additions and 11 deletions

View File

@ -404,20 +404,15 @@ class mailUtilities:
@staticmethod
def changeEmailPassword(email, newPassword, encrypt = None):
try:
changePass = EUsers.objects.get(email=email)
if encrypt == None:
CentOSPath = '/etc/redhat-release'
changePass = EUsers.objects.get(email=email)
if os.path.exists(CentOSPath):
password = bcrypt.hashpw(newPassword.encode('utf-8'), bcrypt.gensalt())
password = '{CRYPT}%s' % (password.decode())
changePass.password = password
else:
changePass.password = newPassword
changePass.save()
# Always use bcrypt hashing regardless of OS
password = bcrypt.hashpw(newPassword.encode('utf-8'), bcrypt.gensalt())
password = '{CRYPT}%s' % (password.decode())
changePass.password = password
else:
changePass = EUsers.objects.get(email=email)
changePass.password = newPassword
changePass.save()
changePass.save()
return 0,'None'
except BaseException as msg:
return 0, str(msg)