mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-03-10 06:10:14 +01:00
Fix webmail account switcher and improve error handling
- Fix apiSSO() resetting selected account to first one on every call, now preserves previously selected account if still valid - Fix webmail.conf ownership to use cyberpanel:cyberpanel (Django runs as cyberpanel user, not nobody) - Add error notifications when SSO or folder loading fails
This commit is contained in:
@@ -740,7 +740,7 @@ module cyberpanel_ols {
|
||||
with open('/etc/cyberpanel/webmail.conf', 'w') as f:
|
||||
json_module.dump(webmail_conf, f)
|
||||
os.chmod('/etc/cyberpanel/webmail.conf', 0o600)
|
||||
subprocess.call(['chown', 'nobody:nobody', '/etc/cyberpanel/webmail.conf'])
|
||||
subprocess.call(['chown', 'cyberpanel:cyberpanel', '/etc/cyberpanel/webmail.conf'])
|
||||
|
||||
InstallCyberPanel.stdOut("Webmail master user setup complete!", 1)
|
||||
return 1
|
||||
|
||||
@@ -2846,7 +2846,7 @@ CREATE TABLE `websiteFunctions_backupsv2` (`id` integer AUTO_INCREMENT NOT NULL
|
||||
with open('/etc/cyberpanel/webmail.conf', 'w') as f:
|
||||
json.dump(webmail_conf, f)
|
||||
os.chmod('/etc/cyberpanel/webmail.conf', 0o600)
|
||||
subprocess.call(['chown', 'nobody:nobody', '/etc/cyberpanel/webmail.conf'])
|
||||
subprocess.call(['chown', 'cyberpanel:cyberpanel', '/etc/cyberpanel/webmail.conf'])
|
||||
|
||||
# Patch dovecot.conf if master user config not present
|
||||
dovecot_conf_path = '/etc/dovecot/dovecot.conf'
|
||||
|
||||
@@ -171,6 +171,8 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($
|
||||
$scope.switchEmail = data.email;
|
||||
$scope.loadFolders();
|
||||
$scope.loadSettings();
|
||||
} else {
|
||||
notify(data.error_message || 'No email accounts found. Create an email account first or use the standalone login.', 'error');
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -199,6 +201,8 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($
|
||||
if (data.status === 1) {
|
||||
$scope.folders = data.folders;
|
||||
$scope.loadMessages();
|
||||
} else {
|
||||
notify(data.error_message || 'Failed to load folders.', 'error');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -184,9 +184,12 @@ class WebmailManager:
|
||||
accounts = self._get_managed_accounts()
|
||||
if not accounts:
|
||||
return self._error('No email accounts found for your user.')
|
||||
email = accounts[0]
|
||||
self.request.session['webmail_email'] = email
|
||||
return self._success({'email': email, 'accounts': accounts})
|
||||
# Preserve previously selected account if still valid
|
||||
current = self.request.session.get('webmail_email')
|
||||
if not current or current not in accounts:
|
||||
current = accounts[0]
|
||||
self.request.session['webmail_email'] = current
|
||||
return self._success({'email': current, 'accounts': accounts})
|
||||
|
||||
def apiListAccounts(self):
|
||||
accounts = self._get_managed_accounts()
|
||||
|
||||
Reference in New Issue
Block a user