diff --git a/Foundation.hs b/Foundation.hs index 0d292fd..879475a 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -8,6 +8,7 @@ import Yesod.Auth.BrowserId (authBrowserId) import Yesod.Default.Util (addStaticContentExternal) import Yesod.Core.Types (Logger) import qualified Yesod.Core.Unsafe as Unsafe +import Yesod.Auth.HashDB (authHashDB, getAuthIdHashDB) -- | The foundation datatype for your application. This can be a good place to -- keep settings and values requiring initialization before your application @@ -121,21 +122,18 @@ instance YesodAuth App where -- Override the above two destinations when a Referer: header is present redirectToReferer _ = True - getAuthId creds = do - now <- liftIO getCurrentTime + getAuthId creds = getAuthIdHashDB AuthR (Just . UniqueUser) creds --authenticate on own site + --TODO: Authenticate via OAuth2 + {-do runDB $ do x <- getBy $ UniqueUser $ credsIdent creds case x of Just (Entity uid _) -> return $ Just uid - Nothing -> do - fmap Just $ insert User - { userIdent = credsIdent creds - , userPassword = Nothing - , userLastLogin = now - } + Nothing -> return Nothing-} -- You can add other plugins like BrowserID, email or OAuth here authPlugins _ = [ authBrowserId def + , authHashDB (Just . UniqueUser) ] authHttpManager = getHttpManager diff --git a/Handler/Home.hs b/Handler/Home.hs index b0d3f93..130419a 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -1,9 +1,6 @@ module Handler.Home where import Import -import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, - withSmallInput, withPlaceholder, bfs, - withAutofocus) -- This is a handler function for the GET request method on the HomeR -- resource pattern. All of your resource patterns are defined in @@ -15,7 +12,6 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, getHomeR :: Handler Html getHomeR = do maid <- maybeAuthId - (loginWidget, loginEnctype) <- generateFormPost loginForm defaultLayout $ do setTitle "NEAT" [whamlet| @@ -23,17 +19,16 @@ getHomeR = do Welcome to NEAT.
Current Auth-ID: #{show maid}. +
$maybe u <- maid

Data: #{show u}
Logout $nothing - Login - Login-Page -

- ^{loginWidget} -