yesod-auth 1.3.1 → 1.3.1.1
raw patch · 2 files changed
+12/−6 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Yesod.Auth.Email: class (YesodAuth site, PathPiece (AuthEmailId site), RenderMessage site AuthMessage) => YesodAuthEmail site where type family AuthEmailId site randomKey _ = do { stdgen <- newStdGen; return $ pack $ fst $ randomString 10 stdgen } 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; messageJson401 (mr msg) $ authLayout $ do { setTitleI ConfirmationEmailSentTitle; do { (asWidgetT . toWidget) ((preEscapedText . pack) "<p>"); ((liftM (toHtml .) getMessageRender) >>= (\ urender_ameK -> (asWidgetT . toWidget) (urender_ameK msg))); (asWidgetT . toWidget) ((preEscapedText . pack) "</p>") } } } where msg = ConfirmationEmailSent identifier normalizeEmailAddress _ = toLower registerHandler = defaultRegisterHandler forgotPasswordHandler = defaultForgotPasswordHandler setPasswordHandler = defaultSetPasswordHandler
+ Yesod.Auth.Email: class (YesodAuth site, PathPiece (AuthEmailId site), RenderMessage site AuthMessage) => YesodAuthEmail site where type family AuthEmailId site randomKey _ = do { stdgen <- newStdGen; return $ pack $ fst $ randomString 10 stdgen } 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; messageJson401 (mr msg) $ authLayout $ do { setTitleI ConfirmationEmailSentTitle; do { (asWidgetT . toWidget) ((preEscapedText . pack) "<p>"); ((liftM (toHtml .) getMessageRender) >>= (\ urender_amg5 -> (asWidgetT . toWidget) (urender_amg5 msg))); (asWidgetT . toWidget) ((preEscapedText . pack) "</p>") } } } where msg = ConfirmationEmailSent identifier normalizeEmailAddress _ = toLower registerHandler = defaultRegisterHandler forgotPasswordHandler = defaultForgotPasswordHandler setPasswordHandler = defaultSetPasswordHandler
Files
- Yesod/Auth/GoogleEmail2.hs +11/−5
- yesod-auth.cabal +1/−1
Yesod/Auth/GoogleEmail2.hs view
@@ -53,9 +53,10 @@ import Yesod.Core (HandlerSite, MonadHandler, getRouteToParent, getUrlRender, getYesod, invalidArgs, lift,- liftBase, lookupGetParam,+ lookupGetParam, lookupSession, notFound, redirect,- setSession, whamlet, (.:))+ setSession, whamlet, (.:),+ TypedContent, HandlerT, liftIO) pid :: Text pid = "googleemail2"@@ -75,7 +76,7 @@ case mtoken of Just token -> return token Nothing -> do- stdgen <- liftBase newStdGen+ stdgen <- liftIO newStdGen let token = T.pack $ fst $ randomString 10 stdgen setSession csrfKey token return token@@ -111,6 +112,11 @@ login tm = do url <- getDest tm [whamlet|<a href=#{url}>_{Msg.LoginGoogle}|]++ dispatch :: YesodAuth site+ => Text+ -> [Text]+ -> HandlerT Auth (HandlerT site IO) TypedContent dispatch "GET" ["forward"] = do tm <- getRouteToParent lift (getDest tm) >>= redirect@@ -130,7 +136,7 @@ render <- getUrlRender - req' <- parseUrl "https://accounts.google.com/o/oauth2/token" -- FIXME don't hardcode, use: https://accounts.google.com/.well-known/openid-configuration+ req' <- liftIO $ parseUrl "https://accounts.google.com/o/oauth2/token" -- FIXME don't hardcode, use: https://accounts.google.com/.well-known/openid-configuration let req = urlEncodedBody [ ("code", encodeUtf8 code)@@ -152,7 +158,7 @@ unless (tokenType == "Bearer") $ error $ "Unknown token type: " ++ show tokenType - req2' <- parseUrl "https://www.googleapis.com/plus/v1/people/me"+ req2' <- liftIO $ parseUrl "https://www.googleapis.com/plus/v1/people/me" let req2 = req2' { requestHeaders = [ ("Authorization", encodeUtf8 $ "Bearer " `mappend` accessToken)
yesod-auth.cabal view
@@ -1,5 +1,5 @@ name: yesod-auth-version: 1.3.1+version: 1.3.1.1 license: MIT license-file: LICENSE author: Michael Snoyman, Patrick Brisbin