11-- Copyright © 2015-2016 Nejla AB. All rights reserved.
22
3+ {-# LANGUAGE NoMonomorphismRestriction #-}
34{-# LANGUAGE TemplateHaskell #-}
45{-# LANGUAGE OverloadedStrings #-}
56
@@ -10,6 +11,7 @@ import Control.Monad.Logger
1011import Control.Monad.Trans
1112import Data.ByteString (ByteString )
1213import qualified Data.ByteString as BS
14+ import Data.Char
1315import qualified Data.Configurator as Conf
1416import qualified Data.Configurator.Types as Conf
1517import Data.Maybe (catMaybes )
@@ -96,6 +98,18 @@ getConf :: (MonadLogger m, MonadIO m) =>
9698 String -> Conf. Name -> Either Text Text -> Conf. Config -> m Text
9799getConf = getConfGeneric (Just . Text. pack)
98100
101+ getConfBool :: (MonadIO m , MonadLogger m ) =>
102+ String
103+ -> Conf. Name
104+ -> Either Text Bool
105+ -> Conf. Config
106+ -> m Bool
107+ getConfBool = getConfGeneric parseBool
108+ where
109+ parseBool str | (map toLower $ str) == " true" = Just True
110+ | (map toLower $ str) == " false" = Just False
111+ | otherwise = Nothing
112+
99113loadConf :: MonadIO m => m Conf. Config
100114loadConf = liftIO $ do
101115 mbConfPath <- lookupEnv " CONF_PATH"
@@ -146,7 +160,7 @@ getTwilioConfig conf = do
146160 liftIO Exit. exitFailure
147161
148162get2FAConf conf = do
149- tfaRequired <- getConf' " TFA_REQUIRED" " tfa.required" (Right False ) conf
163+ tfaRequired <- getConfBool " TFA_REQUIRED" " tfa.required" (Right False ) conf
150164 twilioConf <- getTwilioConfig conf
151165 case (tfaRequired, twilioConf) of
152166 (True , Nothing ) -> do
0 commit comments