Created
January 25, 2017 18:33
-
-
Save Tehnix/c83e415811ed5e61b32d28d88f5bbeb8 to your computer and use it in GitHub Desktop.
Overwrite loginHandler (not working atm)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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