diff --git a/yesod-auth/Yesod/Auth/BrowserId.hs b/yesod-auth/Yesod/Auth/BrowserId.hs
index ddb975ef..9c6e22fe 100644
--- a/yesod-auth/Yesod/Auth/BrowserId.hs
+++ b/yesod-auth/Yesod/Auth/BrowserId.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE OverloadedStrings #-}
module Yesod.Auth.BrowserId
( authBrowserId
+ , authBrowserId'
) where
import Yesod.Auth
@@ -11,6 +12,8 @@ import Data.Text (Text)
import Yesod.Core
import Text.Hamlet (hamlet)
import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text as T
+import Data.Maybe (fromMaybe)
#include "qq.h"
@@ -46,3 +49,33 @@ authBrowserId audience = AuthPlugin
|]
}
+
+authBrowserId' :: YesodAuth m => AuthPlugin m
+authBrowserId' = AuthPlugin
+ { apName = pid
+ , apDispatch = \m ps ->
+ case (m, ps) of
+ ("GET", [assertion]) -> do
+ tm <- getRouteToMaster
+ r <- getUrlRender
+ let audience = T.takeWhile (/= '/') $ stripScheme $ r $ tm LoginR
+ memail <- liftIO $ checkAssertion audience assertion
+ case memail of
+ Nothing -> error "Invalid assertion"
+ Just email -> setCreds True Creds
+ { credsPlugin = pid
+ , credsIdent = email
+ , credsExtra = []
+ }
+ (_, []) -> badMethod
+ _ -> notFound
+ , apLogin = \toMaster -> do
+ addScriptRemote browserIdJs
+ addHamlet [QQ(hamlet)|
+