Improved example for #1544

This commit is contained in:
the-djmaze 2024-04-14 02:16:40 +02:00
parent fffc044998
commit 24681f8955

View file

@ -36,7 +36,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addTemplate('templates/PopupsNextcloudFiles.html'); $this->addTemplate('templates/PopupsNextcloudFiles.html');
$this->addTemplate('templates/PopupsNextcloudCalendars.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('login.credentials', 'loginCredentials');
$this->addHook('imap.before-login', 'beforeLogin'); $this->addHook('imap.before-login', 'beforeLogin');
$this->addHook('smtp.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 public function loginCredentials(string &$sEmail, string &$sLogin, ?string &$sPassword = null) : void
{ {
$ocUser = \OC::$server->getUserSession()->getUser(); $ocUser = \OC::$server->getUserSession()->getUser();
// $sEmail = $ocUser->getEMailAddress() ?: $oc->user->getPrimaryEMailAddress(); $sEmail = $ocUser->getEMailAddress() ?: $oc->user->getPrimaryEMailAddress();
// $sLogin = $ocUser->getUID(); $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 public function beforeLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
{ {
// $oSettings->username = \OC::$server->getUserSession()->getUser()->getUID(); $oSettings->username = \OC::$server->getUserSession()->getUser()->getUID();
// $this->oidcLogin($oAccount, $oClient, $oSettings); $this->oidcLogin($oAccount, $oClient, $oSettings);
} }
// https://apps.nextcloud.com/apps/oidc_login // https://apps.nextcloud.com/apps/oidc_login