401 Unauthorized HTTP status code for JSON-reply login fails

This commit is contained in:
Tero Laitinen 2013-05-07 21:31:51 +03:00
parent 6db31ec3c4
commit 021b0f48f9

View File

@ -89,7 +89,7 @@ import Data.Digest.Pure.SHA (sha1, showDigest)
import Data.Text (Text, pack, unpack, append)
import Data.Maybe (fromMaybe)
import System.Random (randomRIO)
import Network.HTTP.Types (unauthorized401)
-- | Interface for data type which holds user info. It's just a
-- collection of getters and setters
class HashDBUser user where
@ -189,7 +189,7 @@ loginMsg dest msg = selectRep (do
fmap asHtml $ redirect dest
provideRep $ return $ object
[ "message" .= msg
]) >>= sendResponse
]) >>= sendResponseStatus unauthorized401
where
asHtml :: Html -> Html
asHtml = id