allow multi-account in nc with oauth login

This commit is contained in:
the-djmaze 2024-08-06 21:41:52 +02:00 committed by Akhil
parent fa15742edb
commit 97c0f81a2e
6 changed files with 15 additions and 13 deletions

View file

@ -90,8 +90,15 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
public function beforeLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
{
// https://apps.nextcloud.com/apps/oidc_login
$ocUser = \OC::$server->getUserSession()->getUser();
$sNcEmail = $ocUser->getEMailAddress() ?: $ocUser->getPrimaryEMailAddress();
// Only login with OIDC access token if
// it is enabled in config, the user is currently logged in with OIDC
// and the current snappymail account is the OIDC account
if (\OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-autologin-oidc', false)
&& \OC::$server->getSession()->get('is_oidc')
&& $sNcEmail === $oSettings->username
// && $oClient->supportsAuthType('OAUTHBEARER') // v2.28
) {
$sAccessToken = \OC::$server->getSession()->get('oidc_access_token');