diff --git a/src/Server.hs b/src/Server.hs index 9524623f2..3e9a4ebb0 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -69,10 +69,9 @@ verifyTransmission signature connId cmd = do conn <- getConn store party connId either (return . smpErr) f conn verifySend :: Maybe PublicKey -> m Cmd - verifySend = - if null signature - then return . maybe cmd (const authErr) - else maybe (return authErr) verifySignature + verifySend + | null signature = return . maybe cmd (const authErr) + | otherwise = maybe (return authErr) verifySignature -- TODO stub verifySignature :: PublicKey -> m Cmd verifySignature key = return $ if signature == key then cmd else authErr diff --git a/src/Transport.hs b/src/Transport.hs index b6b1ed608..6d6ab090c 100644 --- a/src/Transport.hs +++ b/src/Transport.hs @@ -92,25 +92,21 @@ tGet fromParty h = do -- ERROR response does not always have connection ID Cmd SBroker (ERROR _) -> Right cmd -- other responses must have connection ID - Cmd SBroker _ -> - if null connId - then Left $ SYNTAX errNoConnectionId - else Right cmd + Cmd SBroker _ + | null connId -> Left $ SYNTAX errNoConnectionId + | otherwise -> Right cmd -- CREATE must NOT have signature or connection ID - Cmd SRecipient (CREATE _) -> - if null signature && null connId - then Right cmd - else Left $ SYNTAX errHasCredentials + Cmd SRecipient (CREATE _) + | null signature && null connId -> Right cmd + | otherwise -> Left $ SYNTAX errHasCredentials -- SEND must have connection ID, signature is not always required - Cmd SSender (SEND _) -> - if null connId - then Left $ SYNTAX errNoConnectionId - else Right cmd + Cmd SSender (SEND _) + | null connId -> Left $ SYNTAX errNoConnectionId + | otherwise -> Right cmd -- other client commands must have both signature and connection ID - _ -> - if null signature || null connId - then Left $ SYNTAX errNoCredentials - else Right cmd + _ + | null signature || null connId -> Left $ SYNTAX errNoCredentials + | otherwise -> Right cmd cmdWithMsgBody :: Cmd -> m (Either ErrorType Cmd) cmdWithMsgBody = \case