From 8b0dadb645a37cebd77be36ce59a4902d2aa9902 Mon Sep 17 00:00:00 2001 From: nek0 Date: Fri, 13 Dec 2019 23:48:09 +0100 Subject: [PATCH] commence prouct pages --- src/Control/Product.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Control/Product.hs b/src/Control/Product.hs index c467067..542d782 100644 --- a/src/Control/Product.hs +++ b/src/Control/Product.hs @@ -55,14 +55,20 @@ productStockUpdate :: Maybe (Int, AuthMethod) -> [AmountUpdate] -> MateHandler () -productStockUpdate (Just _) amoups = - if all ((>= 0) . amountUpdateRealAmount) amoups - then do - conn <- asks rsConnection - void $ manualProductAmountUpdate amoups conn +productStockUpdate (Just (_, method)) amoups = + if method `elem` [PrimaryPass, ChallengeResponse] + then + if all ((>= 0) . amountUpdateRealAmount) amoups + then do + conn <- asks rsConnection + void $ manualProductAmountUpdate amoups conn + else + throwError $ err400 + { errBody = "Amounts less than 0 are not acceptable." + } else - throwError $ err400 - { errBody = "Amounts less than 0 are not acceptable." + throwError $ err401 + { errBody = "Wrong Authentication present." } productStockUpdate Nothing _ = throwError $ err401