From 24681f89556bf47186b3e59ca5a5d891611a8ae8 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 14 Apr 2024 02:16:40 +0200 Subject: [PATCH] Improved example for #1544 --- plugins/nextcloud/index.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/nextcloud/index.php b/plugins/nextcloud/index.php index a47999eb9..163f27a4b 100644 --- a/plugins/nextcloud/index.php +++ b/plugins/nextcloud/index.php @@ -36,7 +36,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin $this->addTemplate('templates/PopupsNextcloudFiles.html'); $this->addTemplate('templates/PopupsNextcloudCalendars.html'); /* - $this->addHook('login.credentials.step-2', 'loginCredentials'); + $this->addHook('login.credentials.step-2', 'loginCredentials2'); $this->addHook('login.credentials', 'loginCredentials'); $this->addHook('imap.before-login', 'beforeLogin'); $this->addHook('smtp.before-login', 'beforeLogin'); @@ -74,14 +74,20 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin public function loginCredentials(string &$sEmail, string &$sLogin, ?string &$sPassword = null) : void { $ocUser = \OC::$server->getUserSession()->getUser(); -// $sEmail = $ocUser->getEMailAddress() ?: $oc->user->getPrimaryEMailAddress(); -// $sLogin = $ocUser->getUID(); + $sEmail = $ocUser->getEMailAddress() ?: $oc->user->getPrimaryEMailAddress(); + $sLogin = $ocUser->getUID(); + } + + public function loginCredentials2(string &$sEmail, ?string &$sPassword = null) : void + { + $ocUser = \OC::$server->getUserSession()->getUser(); + $sEmail = $ocUser->getEMailAddress() ?: $oc->user->getPrimaryEMailAddress(); } public function beforeLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void { -// $oSettings->username = \OC::$server->getUserSession()->getUser()->getUID(); -// $this->oidcLogin($oAccount, $oClient, $oSettings); + $oSettings->username = \OC::$server->getUserSession()->getUser()->getUID(); + $this->oidcLogin($oAccount, $oClient, $oSettings); } // https://apps.nextcloud.com/apps/oidc_login