packages feed

yesod-auth 1.4.15 → 1.4.16

raw patch · 3 files changed

+66/−9 lines, 3 filesdep ~yesod-corePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: yesod-core

API changes (from Hackage documentation)

- Yesod.Auth.Email: class (YesodAuth site, PathPiece (AuthEmailId site), RenderMessage site AuthMessage) => YesodAuthEmail site where type AuthEmailId site randomKey _ = nonce128urlT defaultNonceGen needOldPassword aid' = do { mkey <- lookupSession loginLinkKey; case mkey >>= readMay . unpack of { Just (aidT, time) | Just aid <- fromPathPiece aidT, toPathPiece (aid `asTypeOf` aid') == toPathPiece aid' -> do { now <- liftIO getCurrentTime; return $ addUTCTime (60 * 30) time <= now } _ -> return True } } checkPasswordSecurity _ x | length x >= 3 = return $ Right () | otherwise = return $ Left "Password must be at least three characters" confirmationEmailSentResponse identifier = do { mr <- getMessageRender; selectRep $ do { provideJsonMessage (mr msg); provideRep $ authLayout $ do { setTitleI ConfirmationEmailSentTitle; (do { (asWidgetT . toWidget) ((preEscapedText . pack) "<p>"); ((fmap (toHtml .) getMessageRender) >>= (\ urender_aLCz -> (asWidgetT . toWidget) (urender_aLCz msg))); (asWidgetT . toWidget) ((preEscapedText . pack) "</p>\n") }) } } } where msg = ConfirmationEmailSent identifier normalizeEmailAddress _ = toLower registerHandler = defaultRegisterHandler forgotPasswordHandler = defaultForgotPasswordHandler setPasswordHandler = defaultSetPasswordHandler where {
+ Yesod.Auth.Email: class (YesodAuth site, PathPiece (AuthEmailId site), RenderMessage site AuthMessage) => YesodAuthEmail site where type AuthEmailId site randomKey _ = nonce128urlT defaultNonceGen needOldPassword aid' = do { mkey <- lookupSession loginLinkKey; case mkey >>= readMay . unpack of { Just (aidT, time) | Just aid <- fromPathPiece aidT, toPathPiece (aid `asTypeOf` aid') == toPathPiece aid' -> do { now <- liftIO getCurrentTime; return $ addUTCTime (60 * 30) time <= now } _ -> return True } } checkPasswordSecurity _ x | length x >= 3 = return $ Right () | otherwise = return $ Left "Password must be at least three characters" confirmationEmailSentResponse identifier = do { mr <- getMessageRender; selectRep $ do { provideJsonMessage (mr msg); provideRep $ authLayout $ do { setTitleI ConfirmationEmailSentTitle; (do { (asWidgetT . toWidget) ((preEscapedText . pack) "<p>"); ((fmap (toHtml .) getMessageRender) >>= (\ urender_aLTh -> (asWidgetT . toWidget) (urender_aLTh msg))); (asWidgetT . toWidget) ((preEscapedText . pack) "</p>\n") }) } } } where msg = ConfirmationEmailSent identifier normalizeEmailAddress _ = toLower registerHandler = defaultRegisterHandler forgotPasswordHandler = defaultForgotPasswordHandler setPasswordHandler = defaultSetPasswordHandler where {
- Yesod.Auth.Email: randomKey :: YesodAuthEmail site => site -> IO Text
+ Yesod.Auth.Email: randomKey :: YesodAuthEmail site => site -> IO VerKey

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.4.16++* Fix email provider [#1330](https://github.com/yesodweb/yesod/issues/1330)+ ## 1.4.15  * Add JSON endpoints to Yesod.Auth.Email module
Yesod/Auth/Email.hs view
@@ -28,6 +28,60 @@ --     * logout and sign in --     * reset their password --+-- = Using JSON Endpoints+--+-- We are assuming that you have declared auth route as follows+-- +-- @+--    /auth AuthR Auth getAuth+-- @+-- +-- If you are using a different route, then you have to adjust the+-- endpoints accordingly.+--+--     * Registration+-- +-- @+--       Endpoint: \/auth\/page\/email\/register+--       Method: POST+--       JSON Data: { "email": "myemail@domain.com" }+-- @+-- +--     * Forgot password+--  +-- @+--       Endpoint: \/auth\/page\/email\/forgot-password+--       Method: POST+--       JSON Data: { "email": "myemail@domain.com" }+-- @+--+--     * Login+--  +-- @+--       Endpoint: \/auth\/page\/email\/login+--       Method: POST+--       JSON Data: { +--                      "email": "myemail@domain.com",+--                      "password": "myStrongPassword"+--                  }+-- @+-- +--     * Set new password+--+-- @+--       Endpoint: \/auth\/page\/email\/set-password+--       Method: POST+--       JSON Data: {+--                       "new": "newPassword",+--                       "confirm": "newPassword",+--                       "current": "currentPassword"+--                  }+-- @+--+--  Note that in the set password endpoint, the presence of the key+--  "current" is dependent on how the 'needOldPassword' is defined in+--  the instance for 'YesodAuthEmail'.+ module Yesod.Auth.Email     ( -- * Plugin       authEmail@@ -184,7 +238,7 @@     -- | Generate a random alphanumeric string.     --     -- @since 1.1.0-    randomKey :: site -> IO Text+    randomKey :: site -> IO VerKey     randomKey _ = Nonce.nonce128urlT defaultNonceGen      -- | Route to send user to after password has been set correctly.@@ -401,12 +455,11 @@     pidentifier <- lookupPostParam "email"     midentifier <- case pidentifier of                      Nothing -> do-                       (jidentifier :: Result Value) <- lift parseJsonBody                                     +                       (jidentifier :: Result Value) <- lift parseCheckJsonBody                        case jidentifier of                          Error _ -> return Nothing                          Success val -> return $ parseMaybe parseEmail val                      Just _ -> return pidentifier-                                       let eidentifier = case midentifier of                           Nothing -> Left Msg.NoIdentifierProvided                           Just x@@ -532,15 +585,15 @@     result <- lift $ runInputPostResult $ (,)         <$> ireq textField "email"         <*> ireq textField "password"-    +     midentifier <- case result of                      FormSuccess (iden, pass) -> return $ Just (iden, pass)                      _ -> do-                       (creds :: Result Value) <- lift parseJsonBody+                       (creds :: Result Value) <- lift parseCheckJsonBody                        case creds of                          Error _ -> return Nothing                          Success val -> return $ parseMaybe parseCreds val-                                              +     case midentifier of       Nothing -> loginErrorMessageI LoginR Msg.NoIdentifierProvided       Just (identifier, pass) -> do@@ -665,7 +718,7 @@ postPasswordR :: YesodAuthEmail master => HandlerT Auth (HandlerT master IO) TypedContent postPasswordR = do     maid <- lift maybeAuthId-    (creds :: Result Value) <- lift parseJsonBody+    (creds :: Result Value) <- lift parseCheckJsonBody     let jcreds = case creds of                    Error _ -> Nothing                    Success val -> parseMaybe parsePassword val
yesod-auth.cabal view
@@ -1,5 +1,5 @@ name:            yesod-auth-version:         1.4.15+version:         1.4.16 license:         MIT license-file:    LICENSE author:          Michael Snoyman, Patrick Brisbin@@ -23,7 +23,7 @@     build-depends:   base                    >= 4         && < 5                    , authenticate            >= 1.3                    , bytestring              >= 0.9.1.4-                   , yesod-core              >= 1.4.20    && < 1.5+                   , yesod-core              >= 1.4.31    && < 1.5                    , wai                     >= 1.4                    , template-haskell                    , base16-bytestring