mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
bug fix: restore email password
This commit is contained in:
@@ -695,7 +695,7 @@ class backupUtilities:
|
||||
username = email.split("@")[0]
|
||||
password = emailAccount.find('password').text
|
||||
|
||||
result = mailUtilities.createEmailAccount(masterDomain, username, password)
|
||||
result = mailUtilities.createEmailAccount(masterDomain, username, password, 'restore')
|
||||
if result[0] == 0:
|
||||
raise BaseException(result[1])
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class mailUtilities:
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
@staticmethod
|
||||
def createEmailAccount(domain, userName, password):
|
||||
def createEmailAccount(domain, userName, password, restore = None):
|
||||
try:
|
||||
|
||||
## Check if already exists
|
||||
@@ -139,12 +139,14 @@ class mailUtilities:
|
||||
CentOSPath = '/etc/redhat-release'
|
||||
|
||||
if os.path.exists(CentOSPath):
|
||||
if restore == None:
|
||||
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
|
||||
password = '{CRYPT}%s' % (password.decode())
|
||||
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
|
||||
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)
|
||||
emailAcct.save()
|
||||
else:
|
||||
if restore == None:
|
||||
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
|
||||
password = '{CRYPT}%s' % (password.decode())
|
||||
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
|
||||
|
||||
Reference in New Issue
Block a user