diff --git a/src/Control/Journal.hs b/src/Control/Journal.hs index 209cb36..72dc380 100644 --- a/src/Control/Journal.hs +++ b/src/Control/Journal.hs @@ -15,9 +15,15 @@ journalShow -> Maybe Int -> Maybe Int -> MateHandler [JournalEntry] -journalShow (Just _) mlimit moffset = do - conn <- asks rsConnection - selectJournalEntries mlimit moffset conn +journalShow (Just (_, method)) mlimit moffset = do + if method `elem` [PrimaryPass, ChallengeResponse] + then do + conn <- asks rsConnection + selectJournalEntries mlimit moffset conn + else + throwError $ err401 + { errBody = "Wrong Authentication present" + } journalShow Nothing _ _ = throwError $ err401 { errBody = "No Authentication present" diff --git a/src/Model/Journal.hs b/src/Model/Journal.hs index d487f2a..38f9b28 100644 --- a/src/Model/Journal.hs +++ b/src/Model/Journal.hs @@ -3,7 +3,7 @@ {-# LANGUAGE Arrows #-} module Model.Journal where -import Data.Maybe (isJust) +import Data.Maybe (isJust, fromJust) import Data.Time (UTCTime) import Data.Time.Clock @@ -91,11 +91,11 @@ selectJournalEntries mlimit moffset conn = liftIO $ do (JournalEntry id_ descr ts (tot - before) tot check : fin, tot) ) ( [] - , if isJust mlimit && not (null entries) + , if isJust mlimit && length entries > fromJust mlimit then (\(_, _, _, x, _) -> x) (last entries) else 0 ) - ( if isJust mlimit && length entries > 1 + ( if isJust mlimit && length entries > fromJust mlimit then init entries else entries )