Merge pull request #679 from docmunch/master
Added a createOnClickOverride function to BrowserId
This commit is contained in:
commit
9574eda4ae
@ -4,7 +4,7 @@
|
|||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
module Yesod.Auth.BrowserId
|
module Yesod.Auth.BrowserId
|
||||||
( authBrowserId
|
( authBrowserId
|
||||||
, createOnClick
|
, createOnClick, createOnClickOverride
|
||||||
, def
|
, def
|
||||||
, BrowserIdSettings
|
, BrowserIdSettings
|
||||||
, bisAudience
|
, bisAudience
|
||||||
@ -107,14 +107,16 @@ $newline never
|
|||||||
|
|
||||||
-- | Generates a function to handle on-click events, and returns that function
|
-- | Generates a function to handle on-click events, and returns that function
|
||||||
-- name.
|
-- name.
|
||||||
createOnClick :: BrowserIdSettings
|
createOnClickOverride :: BrowserIdSettings
|
||||||
-> (Route Auth -> Route master)
|
-> (Route Auth -> Route master)
|
||||||
|
-> Maybe (Route master)
|
||||||
-> WidgetT master IO Text
|
-> WidgetT master IO Text
|
||||||
createOnClick BrowserIdSettings {..} toMaster = do
|
createOnClickOverride BrowserIdSettings {..} toMaster mOnRegistration = do
|
||||||
unless bisLazyLoad $ addScriptRemote browserIdJs
|
unless bisLazyLoad $ addScriptRemote browserIdJs
|
||||||
onclick <- newIdent
|
onclick <- newIdent
|
||||||
render <- getUrlRender
|
render <- getUrlRender
|
||||||
let login = toJSON $ getPath $ render (toMaster LoginR)
|
let login = toJSON $ getPath $ render loginRoute -- (toMaster LoginR)
|
||||||
|
loginRoute = maybe (toMaster LoginR) id mOnRegistration
|
||||||
toWidget [julius|
|
toWidget [julius|
|
||||||
function #{rawJS onclick}() {
|
function #{rawJS onclick}() {
|
||||||
if (navigator.id) {
|
if (navigator.id) {
|
||||||
@ -152,3 +154,10 @@ createOnClick BrowserIdSettings {..} toMaster = do
|
|||||||
getPath t = fromMaybe t $ do
|
getPath t = fromMaybe t $ do
|
||||||
uri <- parseURI $ T.unpack t
|
uri <- parseURI $ T.unpack t
|
||||||
return $ T.pack $ uriPath uri
|
return $ T.pack $ uriPath uri
|
||||||
|
|
||||||
|
-- | Generates a function to handle on-click events, and returns that function
|
||||||
|
-- name.
|
||||||
|
createOnClick :: BrowserIdSettings
|
||||||
|
-> (Route Auth -> Route master)
|
||||||
|
-> WidgetT master IO Text
|
||||||
|
createOnClick bidSettings toMaster = createOnClickOverride bidSettings toMaster Nothing
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-auth
|
name: yesod-auth
|
||||||
version: 1.2.6
|
version: 1.2.7
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman, Patrick Brisbin
|
author: Michael Snoyman, Patrick Brisbin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user