From 7274341322e91425dee81f476d20e6fa4f4b0311 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 9 Sep 2013 15:01:20 +0200 Subject: [PATCH] normalizeEmailAddress --- yesod-auth/Yesod/Auth/Email.hs | 13 ++++++++++++- yesod-auth/yesod-auth.cabal | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/yesod-auth/Yesod/Auth/Email.hs b/yesod-auth/Yesod/Auth/Email.hs index 70024aff..e9df5fda 100644 --- a/yesod-auth/Yesod/Auth/Email.hs +++ b/yesod-auth/Yesod/Auth/Email.hs @@ -172,6 +172,17 @@ class (YesodAuth site, PathPiece (AuthEmailId site)) => YesodAuthEmail site wher setTitleI Msg.ConfirmationEmailSentTitle [whamlet|

_{Msg.ConfirmationEmailSent identifier}|] + -- | Additional normalization of email addresses, besides standard canonicalization. + -- + -- Default: do nothing. Note that in future versions of Yesod, the default + -- will change to lower casing the email address. At that point, you will + -- need to either ensure your database values are migrated to lower case, + -- or change this default back to doing nothing. + -- + -- Since 1.2.3 + normalizeEmailAddress :: site -> Text -> Text + normalizeEmailAddress _ = TS.toLower + authEmail :: YesodAuthEmail m => AuthPlugin m authEmail = AuthPlugin "email" dispatch $ \tm -> @@ -234,7 +245,7 @@ registerHelper allowUsername dest = do loginErrorMessageI dest Msg.NoIdentifierProvided Just x | Just x' <- Text.Email.Validate.canonicalizeEmail (encodeUtf8 x) -> - return $ decodeUtf8With lenientDecode x' + return $ normalizeEmailAddress y $ decodeUtf8With lenientDecode x' | allowUsername -> return $ TS.strip x | otherwise -> do loginErrorMessageI dest Msg.InvalidEmailAddress diff --git a/yesod-auth/yesod-auth.cabal b/yesod-auth/yesod-auth.cabal index 4717cee7..987f95e4 100644 --- a/yesod-auth/yesod-auth.cabal +++ b/yesod-auth/yesod-auth.cabal @@ -1,5 +1,5 @@ name: yesod-auth -version: 1.2.2 +version: 1.2.3 license: MIT license-file: LICENSE author: Michael Snoyman, Patrick Brisbin