diff --git a/stack.yaml b/stack.yaml index ec929514..2301a9f1 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-3.7 +resolver: lts-5.6 packages: - ./yesod-core - ./yesod-static diff --git a/yesod-auth-oauth/ChangeLog.md b/yesod-auth-oauth/ChangeLog.md index db27428f..8dd1ceac 100644 --- a/yesod-auth-oauth/ChangeLog.md +++ b/yesod-auth-oauth/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.4.1 + +* change OAuth Twitter ID, screen_name → user_id [#1168](https://github.com/yesodweb/yesod/pull/1168) + ## 1.4.0.2 * Compile with GHC 7.10 diff --git a/yesod-auth-oauth/Yesod/Auth/OAuth.hs b/yesod-auth-oauth/Yesod/Auth/OAuth.hs index 79ab12ac..5a8eb79b 100644 --- a/yesod-auth-oauth/Yesod/Auth/OAuth.hs +++ b/yesod-auth-oauth/Yesod/Auth/OAuth.hs @@ -4,6 +4,7 @@ module Yesod.Auth.OAuth ( authOAuth , oauthUrl , authTwitter + , authTwitterUsingUserId , twitterUrl , authTumblr , tumblrUrl @@ -89,11 +90,12 @@ mkExtractCreds name idName (Credential dic) = do Just crId -> return $ Creds name crId $ map (bsToText *** bsToText) dic Nothing -> throwIO $ CredentialError ("key not found: " ++ idName) (Credential dic) -authTwitter :: YesodAuth m - => ByteString -- ^ Consumer Key - -> ByteString -- ^ Consumer Secret - -> AuthPlugin m -authTwitter key secret = authOAuth +authTwitter' :: YesodAuth m + => ByteString -- ^ Consumer Key + -> ByteString -- ^ Consumer Secret + -> String + -> AuthPlugin m +authTwitter' key secret idName = authOAuth (newOAuth { oauthServerName = "twitter" , oauthRequestUri = "https://api.twitter.com/oauth/request_token" , oauthAccessTokenUri = "https://api.twitter.com/oauth/access_token" @@ -103,7 +105,26 @@ authTwitter key secret = authOAuth , oauthConsumerSecret = secret , oauthVersion = OAuth10a }) - (mkExtractCreds "twitter" "screen_name") + (mkExtractCreds "twitter" idName) + +-- | This plugin uses Twitter's /screen_name/ as ID, which shouldn't be used for authentication because it is mutable. +authTwitter :: YesodAuth m + => ByteString -- ^ Consumer Key + -> ByteString -- ^ Consumer Secret + -> AuthPlugin m +authTwitter key secret = authTwitter' key secret "screen_name" +{-# DEPRECATED authTwitter "Use authTwitterUsingUserID instead" #-} + +-- | Twitter plugin which uses Twitter's /user_id/ as ID. +-- +-- For more information, see: https://github.com/yesodweb/yesod/pull/1168 +-- +-- @since 1.4.1 +authTwitterUsingUserId :: YesodAuth m + => ByteString -- ^ Consumer Key + -> ByteString -- ^ Consumer Secret + -> AuthPlugin m +authTwitterUsingUserId key secret = authTwitter' key secret "user_id" twitterUrl :: AuthRoute twitterUrl = oauthUrl "twitter" diff --git a/yesod-auth-oauth/yesod-auth-oauth.cabal b/yesod-auth-oauth/yesod-auth-oauth.cabal index be3659ef..6a952db6 100644 --- a/yesod-auth-oauth/yesod-auth-oauth.cabal +++ b/yesod-auth-oauth/yesod-auth-oauth.cabal @@ -1,5 +1,5 @@ name: yesod-auth-oauth -version: 1.4.0.2 +version: 1.4.1 license: BSD3 license-file: LICENSE author: Hiromi Ishii diff --git a/yesod-auth/ChangeLog.md b/yesod-auth/ChangeLog.md index 970cd994..aa6b0669 100644 --- a/yesod-auth/ChangeLog.md +++ b/yesod-auth/ChangeLog.md @@ -1,3 +1,8 @@ +## 1.4.13 + +* Add a CSRF token to the login form from `Yesod.Auth.Hardcoded`, making it compatible with the CSRF middleware [#1161](https://github.com/yesodweb/yesod/pull/1161) +* Multiple session messages. [#1187](https://github.com/yesodweb/yesod/pull/1187) + ## 1.4.12 * Deprecated Yesod.Auth.GoogleEmail diff --git a/yesod-auth/Yesod/Auth.hs b/yesod-auth/Yesod/Auth.hs index 70ecde59..8d251af0 100644 --- a/yesod-auth/Yesod/Auth.hs +++ b/yesod-auth/Yesod/Auth.hs @@ -189,9 +189,9 @@ class (Yesod master, PathPiece (AuthId master), RenderMessage master FormMessage authHttpManager :: master -> Manager -- | Called on a successful login. By default, calls - -- @setMessageI NowLoggedIn@. + -- @addMessageI "success" NowLoggedIn@. onLogin :: HandlerT master IO () - onLogin = setMessageI Msg.NowLoggedIn + onLogin = addMessageI "success" Msg.NowLoggedIn -- | Called on logout. By default, does nothing onLogout :: HandlerT master IO () @@ -214,10 +214,10 @@ class (Yesod master, PathPiece (AuthId master), RenderMessage master FormMessage maybeAuthId = defaultMaybeAuthId -- | Called on login error for HTTP requests. By default, calls - -- @setMessage@ and redirects to @dest@. + -- @addMessage@ with "error" as status and redirects to @dest@. onErrorHtml :: (MonadResourceBase m) => Route master -> Text -> HandlerT master m Html onErrorHtml dest msg = do - setMessage $ toHtml msg + addMessage "error" $ toHtml msg fmap asHtml $ redirect dest -- | runHttpRequest gives you a chance to handle an HttpException and retry diff --git a/yesod-auth/Yesod/Auth/BrowserId.hs b/yesod-auth/Yesod/Auth/BrowserId.hs index 61e558ea..a63ed0e1 100644 --- a/yesod-auth/Yesod/Auth/BrowserId.hs +++ b/yesod-auth/Yesod/Auth/BrowserId.hs @@ -2,7 +2,10 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE RecordWildCards #-} +-- | NOTE: Mozilla Persona will be shut down by the end of 2016, therefore this +-- module is no longer recommended for use. module Yesod.Auth.BrowserId + {-# DEPRECATED "Mozilla Persona will be shut down by the end of 2016" #-} ( authBrowserId , createOnClick, createOnClickOverride , def diff --git a/yesod-auth/Yesod/Auth/Email.hs b/yesod-auth/Yesod/Auth/Email.hs index 1b94c411..88bba70f 100644 --- a/yesod-auth/Yesod/Auth/Email.hs +++ b/yesod-auth/Yesod/Auth/Email.hs @@ -107,6 +107,11 @@ data EmailCreds site = EmailCreds , emailCredsEmail :: Email } +data ForgotPasswordForm = ForgotPasswordForm { forgotEmail :: Text } +data PasswordForm = PasswordForm { passwordCurrent :: Text, passwordNew :: Text, passwordConfirm :: Text } +data UserForm = UserForm { email :: Text } +data UserLoginForm = UserLoginForm { loginEmail :: Text, loginPassword :: Text } + class ( YesodAuth site , PathPiece (AuthEmailId site) , (RenderMessage site Msg.AuthMessage) @@ -253,30 +258,9 @@ class ( YesodAuth site -> AuthHandler site TypedContent setPasswordHandler = defaultSetPasswordHandler - -authEmail :: YesodAuthEmail m => AuthPlugin m +authEmail :: (YesodAuthEmail m) => AuthPlugin m authEmail = - AuthPlugin "email" dispatch $ \tm -> - [whamlet| -$newline never -