Skip to content

Instantly share code, notes, and snippets.

@Tehnix
Created January 25, 2017 18:33
Show Gist options
  • Save Tehnix/c83e415811ed5e61b32d28d88f5bbeb8 to your computer and use it in GitHub Desktop.
Save Tehnix/c83e415811ed5e61b32d28d88f5bbeb8 to your computer and use it in GitHub Desktop.
Overwrite loginHandler (not working atm)
loginHandler = do
ma <- lift maybeAuthId
when (isJust ma) $ lift $ redirect HomeR
toParentRoute <- getRouteToParent
master <- getYesod
(widget, enctype) <- generateFormPost loginForm
lift $
authLayout $ do
setTitle "Log In"
-- mapM_ (flip apLogin toParentRoute) (authPlugins master)
$(widgetFile "auth/login")
where
loginForm extra = do
let emailSettings emailMsg =
FieldSettings
{ fsLabel = "Email"
, fsTooltip = Nothing
, fsId = Just "email"
, fsName = Just "email"
, fsAttrs = [("autofocus", ""), ("placeholder", emailMsg)]
}
let passwordSettings passwordMsg =
FieldSettings
{ fsLabel = "Password"
, fsTooltip = Nothing
, fsId = Just "password"
, fsName = Just "password"
, fsAttrs = [("placeholder", passwordMsg)]
}
(emailRes, emailView) <- mreq emailField (emailSettings "Email") Nothing
(passwordRes, passwordView) <-
mreq passwordField (passwordSettings "Password") Nothing
let userRes = UserLoginForm <$> emailRes <*> passwordRes
let widget = $(widgetFile "auth/login-widget")
return (userRes, widget)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment