Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c69653fb authored by AVINASH GUSAIN's avatar AVINASH GUSAIN
Browse files

login with device fix

parent 1876f09d
Loading
Loading
Loading
Loading
Loading
+24 −18
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ diff --git ./core/Controller/LoginController.php ./core/Controller/LoginControll
 		$data = new LoginData(
 			$this->request,
 			trim($user),
--- ./core/Controller/WebAuthnController.php	2022-08-18 10:14:10.940199100 +0530
+++ ./core/Controller/WebAuthnController-new.php	2022-08-18 10:14:17.280199100 +0530
--- ./core/Controller/WebAuthnController.php	2022-08-18 10:33:16.150199100 +0530
+++ ./core/Controller/WebAuthnController-new.php	2022-08-18 10:34:31.880199100 +0530
@@ -37,6 +37,7 @@
 use OCP\ISession;
 use OCP\Util;
@@ -47,26 +47,32 @@ diff --git ./core/Controller/LoginController.php ./core/Controller/LoginControll

 class WebAuthnController extends Controller {
 	private const WEBAUTHN_LOGIN = 'webauthn_login';
@@ -75,9 +76,9 @@
@@ -73,6 +74,25 @@

 		$this->logger->debug('Converting login name to UID');
 		$uid = $loginName;
 		$uid = trim($uid);
 		$uid = mb_strtolower($uid, 'UTF-8');
-		$domain = $this->config->getSystemValue('mail_domain', '');
+        $uid = trim($uid);
+		$uid = mb_strtolower($uid, 'UTF-8');
+		$domain = \OC::$server->getConfig()->getSystemValue('mail_domain', '');
 		$domain_suffix = !empty($domain) ? '@' . $domain : '';
-		$alt_domain = $this->config->getSystemValue('alt_mail_domain', '');
+		$domain_suffix = !empty($domain) ? '@' . $domain : '';
+		$alt_domain = \OC::$server->getConfig()->getSystemValue('alt_mail_domain', '');
 		$alt_domain_suffix = !empty($alt_domain) ? '@'  . $alt_domain : '';
 		$admin_username = $_ENV["NEXTCLOUD_ADMIN_USER"];
 		$is_admin = strcmp($uid, $admin_username) === 0;
@@ -89,7 +90,7 @@
 			$uid = str_replace($alt_domain_suffix, '', $uid);
 		}

-		if(!$this->userManager->userExists($uid)) {
+		$alt_domain_suffix = !empty($alt_domain) ? '@'  . $alt_domain : '';
+		$admin_username = $_ENV["NEXTCLOUD_ADMIN_USER"];
+		$is_admin = strcmp($uid, $admin_username) === 0;
+
+		if(!$is_admin && stristr($uid, $domain_suffix) !== FALSE) {
+			$uid = str_replace($domain_suffix, '', $uid);
+		}
+		if (!$is_admin && stristr($uid, $alt_domain_suffix) !== FALSE) {
+			$uid = str_replace($alt_domain_suffix, '', $uid);
+		}
+
+		if(!\OC::$server->get(IUserManager::class)->userExists($uid)) {
 			$uid = $uid . $domain_suffix;
 		}
+			$uid = $uid . $domain_suffix;
+		}
 		Util::emitHook(
 			'\OCA\Files_Sharing\API\Server2Server',
 			'preLoginNameUsedAsUserName',


--- ./lib/private/User/Session.php	2022-08-10 15:39:33.131890282 +0530