From 0ef2c55983df65843922c5f9c880cc70c455651c Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 4 Jan 2024 19:29:28 +0000 Subject: [PATCH] core: invalid name error when it matches hidden profile (#3647) --- src/Simplex/Chat.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index cfd8f224fb..93f10b416b 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -454,8 +454,9 @@ processChatCommand' vr = \case withStore' getUsers >>= \case [] -> pure 1 users -> do - when (any (\User {localDisplayName = n} -> n == displayName) users) $ - throwChatError (CEUserExists displayName) + forM_ users $ \User {localDisplayName = n, activeUser, viewPwdHash} -> + when (n == displayName) . throwChatError $ + if activeUser || isNothing viewPwdHash then CEUserExists displayName else CEInvalidDisplayName {displayName, validName = ""} withAgent (\a -> createUser a smp xftp) ts <- liftIO $ getCurrentTime >>= if pastTimestamp then coupleDaysAgo else pure user <- withStore $ \db -> createUserRecordAt db (AgentUserId auId) p True ts