mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-10-30 17:13:36 +03:00
Nextcloud show initial password in admin settings and option to enable debug mode #96
This commit is contained in:
parent
4faa4db112
commit
37fd11a8cb
3 changed files with 39 additions and 1 deletions
|
|
@ -59,6 +59,14 @@ class FetchController extends Controller {
|
|||
]);
|
||||
}
|
||||
|
||||
\OCA\SnappyMail\Util\SnappyMailHelper::startApp();
|
||||
$debug = !empty($_POST['snappymail-debug']);
|
||||
$oConfig = \RainLoop\Api::Config();
|
||||
if ($debug != $oConfig->Get('debug', 'enable', false)) {
|
||||
$oConfig->Set('debug', 'enable', $debug);
|
||||
$oConfig->Save();
|
||||
}
|
||||
|
||||
return new JSONResponse([
|
||||
'status' => 'success',
|
||||
'Message' => $this->l->t('Saved successfully')
|
||||
|
|
|
|||
|
|
@ -31,6 +31,28 @@ class AdminSettings implements ISettings
|
|||
if (\OC_User::isAdminUser($uid)) {
|
||||
$parameters['snappymail-admin-panel-link'] = SnappyMailHelper::getAppUrl().'?admin';
|
||||
}
|
||||
|
||||
\OCA\SnappyMail\Util\SnappyMailHelper::startApp();
|
||||
$oConfig = \RainLoop\Api::Config();
|
||||
$passfile = APP_PRIVATE_DATA . 'admin_password.txt';
|
||||
$sPassword = $oConfig->Get('security', 'admin_password', '');
|
||||
if (!$sPassword) {
|
||||
$sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12);
|
||||
\RainLoop\Utils::saveFile($passfile, $sPassword . "\n");
|
||||
$oConfig->SetPassword($sPassword);
|
||||
$oConfig->Save();
|
||||
} else if (\is_file($passfile)) {
|
||||
$sPassword = \file_get_contents($passfile);
|
||||
} else {
|
||||
$sPassword = '';
|
||||
}
|
||||
if ($sPassword) {
|
||||
$parameters['snappymail-admin-panel-link'] .= SnappyMailHelper::getAppUrl().'?admin#/security';
|
||||
}
|
||||
$parameters['snappymail-admin-password'] = $sPassword;
|
||||
|
||||
$parameters['snappymail-debug'] = $oConfig->Get('debug', 'enable', false);
|
||||
|
||||
\OCP\Util::addScript('snappymail', 'snappymail');
|
||||
return new TemplateResponse('snappymail', 'admin-local', $parameters);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue