diff --git a/Handler/Login.hs b/Handler/Login.hs index 15b2384..d2125a9 100644 --- a/Handler/Login.hs +++ b/Handler/Login.hs @@ -25,7 +25,7 @@ postLoginR = do Just user -> do case credentialsPasswd cred == userPassword (entityVal user) of True -> do - setSession "userId" $ pack $ show $ entityKey user + setSession "userId" $ extractKey $ entityKey user setMessage $ [shamlet|
Successfully logged in|]
               redirect $ HomeR
             False -> do
@@ -35,6 +35,12 @@ postLoginR = do
           setMessage $ [shamlet|
User does not exist|]
           redirect $ LoginR
 
+extractKey :: KeyBackend backend entity -> Text
+extractKey = extractKey' . unKey
+  where
+    extractKey' (PersistInt64 k) = pack $ show k
+    extractKey' _ = ""
+
 loginForm :: Form Credentials
 loginForm = renderDivs $ Credentials
   <$> areq textField "Username" Nothing