From efe7546a24bec40750ddcc035d431bd7e2cb019d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 4 Jul 2018 12:27:08 +0200 Subject: [PATCH] Force User fields to be correct --- src/Application.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index 3d23278e7..159fb2655 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -209,8 +209,9 @@ addPWEntry :: FilePath {-^ Password file -} -> User -> Text {-^ Password -} -> IO () -addPWEntry pwFile pwUser' (Text.encodeUtf8 -> pw) = do +addPWEntry pwFile User{..} (Text.encodeUtf8 -> pw) = do (Text.decodeUtf8 -> pwHash) <- makePassword pw 14 - let pwEntry = PWEntry{ pwUser = pwUser', .. } + let pwEntry = PWEntry{ pwUser = User{ userPlugin = "PWFile", .. }, .. } + newUser = userIdent c <- either (const []) id <$> Yaml.decodeFileEither pwFile - Yaml.encodeFile pwFile $ pwEntry : [ c' | c' <- c, ((/=) `on` (userIdent . pwUser)) c' pwEntry ] + Yaml.encodeFile pwFile $ pwEntry : [ c' | c'@(PWEntry{pwUser=User{..}}) <- c, userIdent /= newUser ]