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