...
 
Commits (2)
......@@ -18,6 +18,7 @@ import Network.Wai (pathInfo)
import Text.Hamlet (hamletFile)
import Yesod.Auth
import Yesod.Auth.Email
import Yesod.Auth.Message
import Yesod.Core.Types (Logger)
import qualified Yesod.Core.Unsafe as Unsafe
......@@ -71,7 +72,6 @@ instance Yesod App where
auth <- maybeAuth
let user = case auth of
Nothing -> Nothing
Just (Entity _ (User _ _ _ _ _ _ False)) -> Nothing
Just (Entity uid (User name _ _ _ _ _ _)) -> Just (uid, name)
pc <- widgetToPageContent widget
req <- waiRequest
......@@ -158,9 +158,16 @@ instance YesodPersist App where
authenticateUser :: (YesodPersist site, YesodPersistBackend site ~ SqlBackend, AuthId master ~ Key User) => Text -> HandlerT site IO (AuthenticationResult master)
authenticateUser ident = runDB $ do
joined <- liftIO getCurrentTime
userid <- D.insertOrGet $ User "" ident Nothing Nothing False joined True
return $ Authenticated userid
muser <- getBy $ UniqueUser ident
case muser of
Nothing -> do
joined <- liftIO getCurrentTime
let user = User "" ident Nothing Nothing False joined True
userid <- insert user
return $ Authenticated userid
Just (Entity _ (User _ _ _ _ _ _ False)) ->
return $ UserError $ IdentifierNotFound "This account is closed."
Just (Entity userid _) -> return $ Authenticated userid
instance YesodAuth App where
type AuthId App = UserId
......
<div .container>
^{widget}
<p>
<a href=@{AuthR forgotPasswordR}>reset password