Permalink
Browse files

add echo.hs with auth

  • Loading branch information...
1 parent 5fe91f1 commit 6a6e5c4eb3cff0a444fdaa2d42bdb33b489dab38 @takei-shg takei-shg committed May 3, 2012
Showing with 38 additions and 1 deletion.
  1. +3 −1 Foundation.hs
  2. +12 −0 Handler/Echo.hs
  3. +15 −0 Handler/Register.hs
  4. 0 README
  5. +1 −0 YesodLab.cabal
  6. +7 −0 templates/register.hamlet
View
@@ -11,6 +11,7 @@ module Foundation
, requireAuth
, module Settings
, module Model
+ , module Yesod.Auth
) where
import Prelude
@@ -19,6 +20,7 @@ import Yesod.Static
import Yesod.Auth
import Yesod.Auth.BrowserId
import Yesod.Auth.GoogleEmail
+import Yesod.Auth.OAuth
import Yesod.Default.Config
import Yesod.Default.Util (addStaticContentExternal)
import Yesod.Logger (Logger, logMsg, formatLogText)
@@ -147,7 +149,7 @@ instance YesodAuth App where
fmap Just $ insert $ User (credsIdent creds) Nothing
-- You can add other plugins like BrowserID, email or OAuth here
- authPlugins _ = [authBrowserId, authGoogleEmail]
+ authPlugins _ = [authOAuth]
authHttpManager = httpManager
View
@@ -0,0 +1,12 @@
+module Handler.Echo where
+
+import Import
+
+getEchoR :: Text -> Handler RepHtml
+getEchoR theText = do
+ maid <- maybeAuthId
+ case maid of
+ Nothing ->
+ defaultLayout [whamlet|<p><a href=@{AuthR LoginR}> Go to the login page|]
+ Just authId -> do
+ defaultLayout [whamlet|<h2>#{show maid}|]
View
@@ -0,0 +1,15 @@
+module Handler.Register where
+
+import Import
+
+getRegisterR :: Handler RepHtml
+getRegisterR = do
+ maid <- maybeAuthId
+ muid <- maybeUserId maid
+ case maid of
+ Nothing _ ->
+ defaultLayout [whamlet|<h2>please register|]
+ Just authId ->
+-- (loginWidget, enctype) <- generateFormPost entryForm
+ defaultLayout [whamlet|<h2>You are IN|]
+-- $(widgetFile "login")
View
No changes.
View
@@ -102,6 +102,7 @@ executable YesodLab
, http-conduit >= 1.4 && < 1.5
, directory >= 1.1 && < 1.2
, warp >= 1.2 && < 1.3
+ , yesod-auth-oauth >= 0.0 && < 2.0
, yesod-test
test-suite integration-tests
@@ -0,0 +1,7 @@
+<div class="container" id="maincontainer">
+ <div class="title">
+ <h1>#{title}
+ <div class="registerform">
+ <form method=post enctype=#{enctype}>
+ ^{registerWidget}
+ <input type=submit>

0 comments on commit 6a6e5c4

Please sign in to comment.