diff --git a/lib/Listeners/BeforeTemplateRenderedListener.php b/lib/Listeners/BeforeTemplateRenderedListener.php index adece9c3c691e046cc4b562afef4d6accca6be81..d124d813d0708e3b95c73d9db79aee0a8ab2c1cd 100644 --- a/lib/Listeners/BeforeTemplateRenderedListener.php +++ b/lib/Listeners/BeforeTemplateRenderedListener.php @@ -23,9 +23,6 @@ class BeforeTemplateRenderedListener implements IEventListener { private $appManager; private Util $util; - private const SNAPPYMAIL_APP_ID = 'snappymail'; - private const SNAPPYMAIL_URL = '/apps/snappymail/'; - private const SNAPPYMAIL_AUTOLOGIN_PWD = '1'; public function __construct($appName, IUserSession $userSession, IRequest $request, ISession $session, IConfig $config, IAppManager $appManager, Util $util) { $this->appName = $appName; @@ -41,9 +38,7 @@ class BeforeTemplateRenderedListener implements IEventListener { if (!($event instanceof BeforeTemplateRenderedEvent)) { return; } - if ($this->userSession->isLoggedIn() && $this->appManager->isEnabledForUser(self::SNAPPYMAIL_APP_ID) && strpos($this->request->getPathInfo(), self::SNAPPYMAIL_URL) !== false) { - $this->autoLoginWebmail(); - } + $pathInfo = $this->request->getPathInfo(); if (strpos($pathInfo, '/apps/ecloud-accounts/accounts') !== false) { @@ -51,36 +46,4 @@ class BeforeTemplateRenderedListener implements IEventListener { } } - - - private function autoLoginWebmail() { - $isOidcLogin = $this->session->get('is_oidc'); - if (!$isOidcLogin) { - return; - } - $accountId = $this->getAccountId(); - $actions = \RainLoop\Api::Actions(); - - if (empty($accountId) || $actions->getMainAccountFromToken(false)) { - return; - } - - // Just send over '1' as password to trigger login as the plugin will set the correct access token - $password = self::SNAPPYMAIL_AUTOLOGIN_PWD; // As we cannot pass by reference to LoginProcess - $account = $actions->LoginProcess($accountId, $password, false); - if ($account) { - $actions->Plugins()->RunHook('login.success', array($account)); - $actions->SetAuthToken($account); - } - } - - private function getAccountId(): string { - $username = $this->userSession->getUser()->getUID(); - if ($this->config->getAppValue('snappymail', 'snappymail-autologin', false)) { - return $username; - } - if ($this->config->getAppValue('snappymail', 'snappymail-autologin-with-email', false)) { - return $this->config->getUserValue($username, 'settings', 'email', ''); - } - } }