From 3541c1dc40d477f0b9fe2381b18622931f776dc7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 6 Dec 2018 18:55:06 +0100 Subject: [PATCH] Prevent user from locking themselves out (authpreds) --- src/Handler/Home.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index f4125de79..911827e00 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -283,8 +283,12 @@ getAuthPredsR, postAuthPredsR :: Handler Html getAuthPredsR = postAuthPredsR postAuthPredsR = do (AuthTagActive authTagCurrentActive) <- fromMaybe def <$> lookupSessionJson SessionActiveAuthTags - - let taForm authTag = fromMaybe False <$> aopt checkBoxField (fslI authTag) (Just . Just $ authTagCurrentActive authTag) + + let + blacklist = Set.fromList [ AuthFree, AuthDevelopment, AuthDeprecated ] + taForm authTag + | authTag `Set.member` blacklist = aforced checkBoxField (fslI authTag) (authTagIsActive def authTag) + | otherwise = fromMaybe False <$> aopt checkBoxField (fslI authTag) (Just . Just $ authTagCurrentActive authTag) ((authActiveRes, authActiveWidget), authActiveEnctype) <- runFormPost . renderAForm FormStandard $ AuthTagActive