mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Split Nextcloud SnappyMailHelper
This commit is contained in:
parent
bdea9c6833
commit
04d55be625
4 changed files with 42 additions and 38 deletions
|
|
@ -93,7 +93,7 @@ class Application extends App implements IBootstrap
|
|||
|
||||
$userSession->listen('\OC\User', 'logout', function($user) {
|
||||
$oSession = \OC::$server->getSession()['snappymail-password'] = '';
|
||||
SnappyMailHelper::startApp();
|
||||
SnappyMailHelper::loadApp();
|
||||
\RainLoop\Api::LogoutCurrentLogginedUser();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class FetchController extends Controller {
|
|||
public function upgrade(): JSONResponse {
|
||||
$error = 'Upgrade failed';
|
||||
try {
|
||||
SnappyMailHelper::startApp();
|
||||
SnappyMailHelper::loadApp();
|
||||
if (SnappyMail\Upgrade::core()) {
|
||||
return new JSONResponse([
|
||||
'status' => 'success',
|
||||
|
|
@ -59,7 +59,7 @@ class FetchController extends Controller {
|
|||
]);
|
||||
}
|
||||
|
||||
\OCA\SnappyMail\Util\SnappyMailHelper::startApp();
|
||||
SnappyMailHelper::loadApp();
|
||||
$debug = !empty($_POST['snappymail-debug']);
|
||||
$oConfig = \RainLoop\Api::Config();
|
||||
if ($debug != $oConfig->Get('debug', 'enable', false)) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class AdminSettings implements ISettings
|
|||
$parameters['snappymail-admin-panel-link'] = SnappyMailHelper::getAppUrl().'?admin';
|
||||
}
|
||||
|
||||
\OCA\SnappyMail\Util\SnappyMailHelper::startApp();
|
||||
\OCA\SnappyMail\Util\SnappyMailHelper::loadApp();
|
||||
$oConfig = \RainLoop\Api::Config();
|
||||
$passfile = APP_PRIVATE_DATA . 'admin_password.txt';
|
||||
$sPassword = $oConfig->Get('security', 'admin_password', '');
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ namespace OCA\SnappyMail\Util;
|
|||
class SnappyMailHelper
|
||||
{
|
||||
|
||||
public static function startApp(bool $handle = false) : void
|
||||
public static function loadApp() : void
|
||||
{
|
||||
if (!\class_exists('RainLoop\\Api')) {
|
||||
$_ENV['SNAPPYMAIL_NEXTCLOUD'] = true;
|
||||
|
||||
// Nextcloud the default spl_autoload_register() not working
|
||||
\spl_autoload_register(function($sClassName){
|
||||
$file = RAINLOOP_APP_LIBRARIES_PATH . \strtolower(\strtr($sClassName, '\\', DIRECTORY_SEPARATOR)) . '.php';
|
||||
|
|
@ -18,9 +16,11 @@ class SnappyMailHelper
|
|||
}
|
||||
});
|
||||
|
||||
$_ENV['SNAPPYMAIL_NEXTCLOUD'] = true;
|
||||
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
|
||||
|
||||
require_once \dirname(\dirname(__DIR__)) . '/app/index.php';
|
||||
}
|
||||
|
||||
$oConfig = \RainLoop\Api::Config();
|
||||
$bSave = false;
|
||||
|
|
@ -38,6 +38,11 @@ class SnappyMailHelper
|
|||
$bSave = true;
|
||||
}
|
||||
$bSave && $oConfig->Save();
|
||||
}
|
||||
|
||||
public static function startApp(bool $handle = false) : void
|
||||
{
|
||||
static::loadApp();
|
||||
|
||||
try {
|
||||
$oActions = \RainLoop\Api::Actions();
|
||||
|
|
@ -55,7 +60,6 @@ class SnappyMailHelper
|
|||
} catch (\Throwable $e) {
|
||||
// Ignore login failure
|
||||
}
|
||||
}
|
||||
|
||||
if ($handle) {
|
||||
\header_remove('Content-Security-Policy');
|
||||
|
|
@ -106,13 +110,13 @@ class SnappyMailHelper
|
|||
|
||||
public static function encodePassword(string $sPassword, string $sSalt) : string
|
||||
{
|
||||
static::startApp();
|
||||
static::loadApp();
|
||||
return \SnappyMail\Crypt::EncryptUrlSafe($sPassword, $sSalt);
|
||||
}
|
||||
|
||||
public static function decodePassword(string $sPassword, string $sSalt)/* : mixed */
|
||||
{
|
||||
static::startApp();
|
||||
static::loadApp();
|
||||
return \SnappyMail\Crypt::DecryptUrlSafe($sPassword, $sSalt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue