on master help sign in
captcha
b5b21d6iko
backend/Data/HCaptcha.jsnew file+10
@@ -0,0 +1,10 @@
1+export function bindHCaptchToken(callback) {
2+ return () => {
3+ window.addEventListener("message", (e) => {
4+ if (typeof e.data === 'object' && "hCaptchaToken" in e.data) {
5+ callback(e.data.hCaptchaToken)();
6+ }
7+ })
8+
9+ }
10+}
backend/Data/HCaptcha.pursnew file+6
@@ -0,0 +1,6 @@
1+module Data.HCaptcha where
2+
3+import Prelude
4+import Effect (Effect)
5+
6+foreign import bindHCaptchToken :: (String -> Effect Unit) -> Effect Unit
backend/Main.purs+2
@@ -18,6 +18,7 @@ import Data.Array as Array
18import Data.Clipboard as Clipboard
18import Data.Clipboard as Clipboard
19import Data.DateTime (DateTime)
19import Data.DateTime (DateTime)
20import Data.Either (Either(..))
20import Data.Either (Either(..))
21+import Data.HCaptcha (bindHCaptchToken)
21import Data.JNullable (fromJNullable, jnull, nullify)
22import Data.JNullable (fromJNullable, jnull, nullify)
22import Data.JNullable as JNullable
23import Data.JNullable as JNullable
23import Data.JOpt (fromJOpt)
24import Data.JOpt (fromJOpt)
@@ -50,6 +51,7 @@ main = do
50 storage <- Html.window >>= Window.localStorage
51 storage <- Html.window >>= Window.localStorage
51 services <- WB.getServices
52 services <- WB.getServices
52 masterKeyRef <- Ref.new Nothing
53 masterKeyRef <- Ref.new Nothing
54+ bindHCaptchToken log
53 let run act = do
55 let run act = do
54 maybeKey <- Ref.read masterKeyRef
56 maybeKey <- Ref.read masterKeyRef
55 runElmAff app $ flip runReaderT {app: app, crypto : services.crypto, storage: storage} $
57 runElmAff app $ flip runReaderT {app: app, crypto : services.crypto, storage: storage} $
frontend/Pages/Login.elm+1
@@ -94,6 +94,7 @@ view model =
94 , Attr.attribute "autocomplete" "current-password"
94 , Attr.attribute "autocomplete" "current-password"
95 ]
95 ]
96 []
96 []
97+ , iframe [ Attr.src "https://iko.soy/warden/hcaptcha.html" ] []
97 , alignRight [ button [ Attr.type_ "submit" ] [ text "Log in" ] ]
98 , alignRight [ button [ Attr.type_ "submit" ] [ text "Log in" ] ]
98 ]
99 ]
99 ]
100 ]
packages.dhall+18
@@ -128,3 +128,21 @@ in upstream
128 "https://github.com/ilyakooo0/purescript-argonaut-aeson-generic.git"
128 "https://github.com/ilyakooo0/purescript-argonaut-aeson-generic.git"
129 , version = "purescript-0.14"
129 , version = "purescript-0.14"
130 }
130 }
131+ with untagged-union =
132+ { dependencies =
133+ [ "assert"
134+ , "console"
135+ , "effect"
136+ , "either"
137+ , "foreign"
138+ , "foreign-object"
139+ , "literals"
140+ , "maybe"
141+ , "newtype"
142+ , "prelude"
143+ , "tuples"
144+ , "unsafe-coerce"
145+ ]
146+ , repo = "https://github.com/ilyakooo0/purescript-untagged-union.git"
147+ , version = "ps-15"
148+ }