about summary refs log tree commit diff
path: root/website
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-08T10·18+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-08T10·18+0100
commit926d8e643e9ffb7d5f5608793d35381742675073 (patch)
treec22fe26df1f36112d1f5b31a529adde2e8b38f67 /website
parent3eaf6e5aea5fec270b75283a010a4db4e7ad7801 (diff)
Update jwtIsValid API to return IO Bool
I need IO for:
- Getting the current time to validate `exp`
- Making an HTTP request to Google's token verifier endpoint
Diffstat (limited to 'website')
-rw-r--r--website/sandbox/learnpianochords/src/server/GoogleSignIn.hs4
-rw-r--r--website/sandbox/learnpianochords/src/server/Spec.hs8
2 files changed, 6 insertions, 6 deletions
diff --git a/website/sandbox/learnpianochords/src/server/GoogleSignIn.hs b/website/sandbox/learnpianochords/src/server/GoogleSignIn.hs
index 43fd79fbd619..1ea252eea5ae 100644
--- a/website/sandbox/learnpianochords/src/server/GoogleSignIn.hs
+++ b/website/sandbox/learnpianochords/src/server/GoogleSignIn.hs
@@ -10,5 +10,5 @@ import Web.JWT
 -- * The value of `iss` matches is "accounts.google.com" or
 --   "https://accounts.google.com"
 -- * The `exp` time has not passed
-jwtIsValid :: JWT UnverifiedJWT -> Bool
-jwtIsValid jwt = False
+jwtIsValid :: JWT UnverifiedJWT -> IO Bool
+jwtIsValid jwt = pure False
diff --git a/website/sandbox/learnpianochords/src/server/Spec.hs b/website/sandbox/learnpianochords/src/server/Spec.hs
index 69add5261836..1f9b9bb4bf9c 100644
--- a/website/sandbox/learnpianochords/src/server/Spec.hs
+++ b/website/sandbox/learnpianochords/src/server/Spec.hs
@@ -18,12 +18,12 @@ main = hspec $ do
         let mJWT = F.defaultJWTFields { F.overwriteSigner = hmacSecret "wrong" }
                    |> F.googleJWT
         case mJWT of
-          Nothing -> True == False
-          Just jwt -> GoogleSignIn.jwtIsValid jwt == False
+          Nothing  -> True `shouldBe` False
+          Just jwt -> GoogleSignIn.jwtIsValid jwt `shouldReturn` False
 
       it "returns false when the aud field doesn't match my client ID" $ do
         let mJWT = F.defaultJWTFields { F.overwriteAud = stringOrURI "wrong" }
                   |> F.googleJWT
         case mJWT of
-          Nothing -> True == False
-          Just jwt -> GoogleSignIn.jwtIsValid jwt == False
+          Nothing  -> True `shouldBe` False
+          Just jwt -> GoogleSignIn.jwtIsValid jwt `shouldReturn` False