fix journal

This commit is contained in:
nek0 2019-11-02 22:53:49 +01:00
parent 6624cb1c5a
commit a4cff9f7aa
2 changed files with 12 additions and 6 deletions

View file

@ -15,9 +15,15 @@ journalShow
-> Maybe Int
-> Maybe Int
-> MateHandler [JournalEntry]
journalShow (Just _) mlimit moffset = do
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"

View file

@ -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
)