getUserFromSession :: Connection -> UUID -> ActionM (Maybe CardUser)
getUserFromSession conn uuid = do
    liftIO $ listToMaybe <$> query conn lookupUserQuery (Only uuid)
  where
    lookupUserQuery :: Query
    lookupUserQuery = fromString $ mconcat 
                                [ "SELECT * FROM carduser WHERE id = " 
                                , "(SELECT user_id FROM carduser_session "
                                , "  WHERE id = ? LIMIT 1)"
                                ]
getUserFromSession :: Connection -> UUID -> ActionM (Maybe CardUser)
getUserFromSession conn uuid = do
    liftIO $ listToMaybe <$> query conn lookupUserQuery (Only uuid)
  where
    lookupUserQuery :: Query
    lookupUserQuery = fromString $ mconcat 
                                [ "SELECT * FROM carduser WHERE id = " 
                                , "(SELECT user_id FROM carduser_session "
                                , "  WHERE id = ? LIMIT 1)"
                                ]
getUserFromSession conn uuid = do
    liftIO $ listToMaybe <$> query conn lookupUserQuery (Only uuid)
  where
    lookupUserQuery :: Query
    lookupUserQuery = fromString $ mconcat 
                                [ "SELECT * FROM carduser WHERE id = " 
                                , "(SELECT user_id FROM carduser_session "
                                , "  WHERE id = ? LIMIT 1)"
                                ]