From f4ac9ffa2c5c50eba6298d3ae699b4aa49f8cf82 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Thu, 7 May 2020 16:13:19 +0200
Subject: [PATCH] Remember the webauthn name of devices

Fixes #20289
we should not reset to default once we have logged in with the device.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 lib/private/Authentication/WebAuthn/CredentialRepository.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/private/Authentication/WebAuthn/CredentialRepository.php b/lib/private/Authentication/WebAuthn/CredentialRepository.php
index f4ff950e17b..f75b4b5ae46 100644
--- a/lib/private/Authentication/WebAuthn/CredentialRepository.php
+++ b/lib/private/Authentication/WebAuthn/CredentialRepository.php
@@ -71,7 +71,9 @@ class CredentialRepository implements PublicKeyCredentialSourceRepository {
 		} catch (IMapperException $e) {
 		}
 
+		$defaultName = false;
 		if ($name === null) {
+			$defaultName = true;
 			$name = 'default';
 		}
 
@@ -79,7 +81,7 @@ class CredentialRepository implements PublicKeyCredentialSourceRepository {
 
 		if ($oldEntity) {
 			$entity->setId($oldEntity->getId());
-			if ($name === null) {
+			if ($defaultName) {
 				$entity->setName($oldEntity->getName());
 			}
 		}
-- 
GitLab