mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08: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);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
<a href="<?php echo $_['snappymail-admin-panel-link'] ?>" target="_blank" style="text-decoration: underline">
|
||||
<?php echo($l->t('Go to SnappyMail Webmail admin panel')); ?>
|
||||
</a>
|
||||
<?php if ($_['snappymail-admin-password']) { ?>
|
||||
<br/>
|
||||
Username: admin<br/>
|
||||
Temporary password: <?php echo $_['snappymail-admin-password']; ?>
|
||||
<?php } ?>
|
||||
</p>
|
||||
<br />
|
||||
<?php } ?>
|
||||
|
@ -33,12 +38,15 @@
|
|||
</div>
|
||||
</p>
|
||||
<br />
|
||||
<br />
|
||||
<p>
|
||||
<input id="snappymail-embed" name="snappymail-embed" type="checkbox" class="checkbox" <?php if ($_['snappymail-embed']) echo 'checked="checked"'; ?>>
|
||||
<label for="snappymail-embed">Embed without iframe (experimental)</label>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<input id="snappymail-debug" name="snappymail-debug" type="checkbox" class="checkbox" <?php if ($_['snappymail-debug']) echo 'checked="checked"'; ?>>
|
||||
<label for="snappymail-debug">Debug</label>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<button id="snappymail-save-button" name="snappymail-save-button"><?php echo($l->t('Save')); ?></button>
|
||||
|
|
Loading…
Reference in a new issue