$authSeparator (arg7) replace '@' with '$authSeparator' when authenticating to the IMAP server
(Note: I don't have any server to test this against...)
update lib/IMAP.php
Collect the new variables
diff -u IMAP.php apps/user_external/lib/IMAP.php
--- IMAP.php 2022-04-29 09:29:43.573148672 -0400
+++ apps/user_external/lib/IMAP.php 2022-04-29 09:41:59.878674898 -0400
@@ -25,6 +25,8 @@
private $domain;
private $stripeDomain;
private $groupDomain;
+ private $addEmail;
+ private $authSeparator;
/**
* Create new IMAP authentication provider
@@ -36,7 +38,7 @@
* @param boolean $stripeDomain (whether to stripe the domain part from the username or not)
* @param boolean $groupDomain (whether to add the usere to a group corresponding to the domain of the address)
*/
- public function __construct($mailbox, $port = null, $sslmode = null, $domain = null, $stripeDomain = true, $groupDomain = false) {
+ public function __construct($mailbox, $port = null, $sslmode = null, $domain = null, $stripeDomain = true, $groupDomain = false, $addEmail = false, $authSeparator = null) {
parent::__construct($mailbox);
$this->mailbox = $mailbox;
$this->port = $port === null ? 143 : $port;
@@ -44,6 +46,8 @@
$this->domain = $domain === null ? '' : $domain;
$this->stripeDomain = $stripeDomain;
$this->groupDomain = $groupDomain;
+ $this->addEmail = $addEmail;
+ $this->authSeparator = $authSeparator;
}
Look for the configured authSeparator in the login field and replace it with an '@' to be used for the NC username and email.
/**
@@ -61,12 +65,21 @@
$uid = str_replace("%40", "@", $uid);
}
+ $authseparator = strlen($this->authSeparator) == 1 ? $this->authSeparator : '@';
+
+ // Replace $authseparator with '@' in case the user used the wrong separator...
+ if (!(strpos($uid, '@') !== false) && (strpos($uid, $authseparator) !== false)) {
+ $uid = str_replace($authseparator, "@", $uid);
+ }
+
Set $useremail whenever we set $username. Use $authSeparator in $username for authentication to the IMAP server (addresses [Bug 150] (https://github.com/nextcloud/user_external/issues/150), but I have no server to test against )
Objectives:
Summary:
Add two new config variables
update lib/IMAP.php
Collect the new variables
Look for the configured authSeparator in the login field and replace it with an '@' to be used for the NC username and email.
Set $useremail whenever we set $username. Use $authSeparator in $username for authentication to the IMAP server (addresses [Bug 150] (https://github.com/nextcloud/user_external/issues/150), but I have no server to test against )
Force the NC user id to match the full email (addresses Bug 128 )
Save the user's email in NC config if there's an '@' in it and $addEmail is true