Skip to content

Instantly share code, notes, and snippets.

@Tehnix
Created November 26, 2013 20:56
Show Gist options
  • Save Tehnix/7666077 to your computer and use it in GitHub Desktop.
Save Tehnix/7666077 to your computer and use it in GitHub Desktop.
Trying to overwrite the loginLayout in yesod 1.2.x
-- Snippet from Foundation.hs
instance YesodAuth App where
type AuthId App = UserId
-- Where to send a user after successful login
loginDest _ = AdminR
-- Where to send a user after logout
logoutDest _ = BlogR
getAuthId creds = runDB $ do
x <- getBy $ UniqueUser $ credsIdent creds
case x of
Just (Entity uid _) -> return $ Just uid
Nothing -> do
fmap Just $ insert $ User (credsIdent creds) Nothing
-- You can add other plugins like BrowserID, email or OAuth here
authPlugins _ = [authGoogleEmail]
authHttpManager = httpManager
-- Overwrite the login handler
loginHandler = loginLayout $ do
$(widgetFile "login")
loginLayout :: Widget -> HandlerT Auth (HandlerT App IO) RepHtml
loginLayout widget = do
master <- getYesod
mmsg <- getMessage
pc <- widgetToPageContent $ do
$(combineStylesheets 'StaticR
[ css_normalize_css
, css_bootstrap_css
, css_fonts_css
])
$(combineScripts 'StaticR
[ js_jquery_js
])
$(widgetFile "login-layout")
giveUrlRenderer $(hamletFile "templates/login-layout-wrapper.hamlet")
-- The error
-- Foundation.hs:215:11:
-- Couldn't match expected type `HandlerT App IO'
-- with actual type `IO'
-- Expected type: HandlerT Auth (HandlerT App IO) t0
-- Actual type: HandlerT Auth IO (PageContent (Route Auth))
-- In a stmt of a 'do' block:
-- pc <- widgetToPageContent
-- $ do { $(combineStylesheets 'StaticR [css_normalize_css, ....]);
-- $(combineScripts 'StaticR [js_jquery_js]);
-- $(widgetFile "login-layout") }
-- In the expression:
-- do { master <- getYesod;
-- mmsg <- getMessage;
-- pc <- widgetToPageContent
-- $ do { $(combineStylesheets ... ...);
-- $(combineScripts ... ...);
-- .... };
-- giveUrlRenderer
-- ($(hamletFile "templates/login-layout-wrapper.hamlet")) }
--
-- Foundation.hs:216:11:
-- Couldn't match type `Auth' with `App'
-- Expected type: Route App -> WidgetT Auth IO ()
-- Actual type: Route (HandlerSite (WidgetT Auth IO))
-- -> WidgetT Auth IO ()
-- In the first argument of `(.)', namely `addStylesheet'
-- In the first argument of `mapM_', namely
-- `(addStylesheet . StaticR)'
-- Build failure, pausing...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment