Do parseJsonBody only when form data is not found
This commit is contained in:
parent
0255f93c22
commit
8f8c99db88
@ -399,13 +399,14 @@ registerHelper allowUsername dest = do
|
|||||||
y <- lift getYesod
|
y <- lift getYesod
|
||||||
checkCsrfHeaderOrParam defaultCsrfHeaderName defaultCsrfParamName
|
checkCsrfHeaderOrParam defaultCsrfHeaderName defaultCsrfParamName
|
||||||
pidentifier <- lookupPostParam "email"
|
pidentifier <- lookupPostParam "email"
|
||||||
(jidentifier :: Result Value) <- lift parseJsonBody
|
midentifier <- case pidentifier of
|
||||||
let midentifier = case pidentifier of
|
Nothing -> do
|
||||||
Nothing -> case jidentifier of
|
(jidentifier :: Result Value) <- lift parseJsonBody
|
||||||
Error _ -> Nothing
|
case jidentifier of
|
||||||
Success val -> parseMaybe parseEmail val
|
Error _ -> return Nothing
|
||||||
Just _ -> pidentifier
|
Success val -> return $ parseMaybe parseEmail val
|
||||||
|
Just _ -> return pidentifier
|
||||||
|
|
||||||
let eidentifier = case midentifier of
|
let eidentifier = case midentifier of
|
||||||
Nothing -> Left Msg.NoIdentifierProvided
|
Nothing -> Left Msg.NoIdentifierProvided
|
||||||
Just x
|
Just x
|
||||||
@ -531,12 +532,14 @@ postLoginR = do
|
|||||||
result <- lift $ runInputPostResult $ (,)
|
result <- lift $ runInputPostResult $ (,)
|
||||||
<$> ireq textField "email"
|
<$> ireq textField "email"
|
||||||
<*> ireq textField "password"
|
<*> ireq textField "password"
|
||||||
(creds :: Result Value) <- lift parseJsonBody
|
|
||||||
let midentifier = case result of
|
midentifier <- case result of
|
||||||
FormSuccess (iden, pass) -> Just (iden, pass)
|
FormSuccess (iden, pass) -> return $ Just (iden, pass)
|
||||||
_ -> case creds of
|
_ -> do
|
||||||
Error _ -> Nothing
|
(creds :: Result Value) <- lift parseJsonBody
|
||||||
Success val -> parseMaybe parseCreds val
|
case creds of
|
||||||
|
Error _ -> return Nothing
|
||||||
|
Success val -> return $ parseMaybe parseCreds val
|
||||||
|
|
||||||
case midentifier of
|
case midentifier of
|
||||||
Nothing -> loginErrorMessageI LoginR Msg.NoIdentifierProvided
|
Nothing -> loginErrorMessageI LoginR Msg.NoIdentifierProvided
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user