packages feed

yesod-auth-account 1.2.5 → 1.2.6

raw patch · 4 files changed

+25/−10 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Yesod.Auth.Account: class (YesodAuth master, AccountSendEmail master, AccountDB db, UserCredentials (UserAccount db), RenderMessage master FormMessage) => YesodAuthAccount db master | master -> db where checkValidUsername u | all isAlphaNum u = return $ Right u checkValidUsername _ = do { mr <- getMessageRender; return $ Left $ mr MsgInvalidUsername } unregisteredLogin u = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI MsgEmailUnverified; do { (asWidgetT . toWidget) ((preEscapedText . pack) "<p>"); ((liftM (toHtml .) getMessageRender) >>= (\ urender_a8Ih -> (asWidgetT . toWidget) (urender_a8Ih MsgEmailUnverified))); (asWidgetT . toWidget) ((preEscapedText . pack) "</p>"); (asWidgetT . toWidget) (resendVerifyEmailWidget (username u) tm) } } } getNewAccountR = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI RegisterLong; newAccountWidget tm } } postNewAccountR = do { tm <- getRouteToParent; mr <- lift getMessageRender; ((result, _), _) <- lift $ runFormPost $ renderDivs newAccountForm; mdata <- case result of { FormMissing -> invalidArgs ["Form is missing"] FormFailure msg -> return $ Left msg FormSuccess d -> return $ if newAccountPassword1 d == newAccountPassword2 d then Right d else Left [mr PassMismatch] }; case mdata of { Left errs -> do { setMessage $ toHtml $ concat errs; redirect newAccountR } Right d -> do { void $ lift $ createNewAccount d tm; redirect LoginR } } } allowPasswordReset _ = True getResetPasswordR = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI PasswordResetTitle; resetPasswordWidget tm } } setPasswordHandler u = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI SetPassTitle; newPasswordWidget u tm } }
+ Yesod.Auth.Account: class (YesodAuth master, AccountSendEmail master, AccountDB db, UserCredentials (UserAccount db), RenderMessage master FormMessage) => YesodAuthAccount db master | master -> db where checkValidUsername u | all isAlphaNum u = return $ Right u checkValidUsername _ = do { mr <- getMessageRender; return $ Left $ mr MsgInvalidUsername } unregisteredLogin u = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI MsgEmailUnverified; do { (asWidgetT . toWidget) ((preEscapedText . pack) "<p>"); ((liftM (toHtml .) getMessageRender) >>= (\ urender_a6H4 -> (asWidgetT . toWidget) (urender_a6H4 MsgEmailUnverified))); (asWidgetT . toWidget) ((preEscapedText . pack) "</p>"); (asWidgetT . toWidget) (resendVerifyEmailWidget (username u) tm) } } } getNewAccountR = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI RegisterLong; newAccountWidget tm } } postNewAccountR = do { tm <- getRouteToParent; mr <- lift getMessageRender; ((result, _), _) <- lift $ runFormPost $ renderDivs newAccountForm; mdata <- case result of { FormMissing -> invalidArgs ["Form is missing"] FormFailure msg -> return $ Left msg FormSuccess d -> return $ if newAccountPassword1 d == newAccountPassword2 d then Right d else Left [mr PassMismatch] }; case mdata of { Left errs -> do { setMessage $ toHtml $ concat errs; redirect newAccountR } Right d -> do { void $ lift $ createNewAccount d tm; redirect LoginR } } } allowPasswordReset _ = True getResetPasswordR = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI PasswordResetTitle; resetPasswordWidget tm } } setPasswordHandler u = do { tm <- getRouteToParent; lift $ defaultLayout $ do { setTitleI SetPassTitle; newPasswordWidget u tm } }

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2013 John Lenz+Copyright (c) 2014 John Lenz  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
Yesod/Auth/Account.hs view
@@ -1,4 +1,4 @@-{- Copyright (c) 2013 John Lenz+{- Copyright (c) 2014 John Lenz  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
tests/NewAccount.hs view
@@ -1,11 +1,26 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP, OverloadedStrings #-} module NewAccount (newAccountSpecs) where +import Data.Monoid import Yesod.Auth import Yesod.Test import Foundation import Text.XML.Cursor (attribute)+import qualified Data.Text as T +-- In 9f379bc219bd1fdf008e2c179b03e98a05b36401 (which went into yesod-form-1.3.9)+-- the numbering of fields was changed.  We normally wouldn't care because fields+-- can be set via 'byLabel', but hidden fields have no label so we must use the id+-- directly. We temporarily support both versions of yesod form with the following.+f1, f2 :: T.Text+#if MIN_VERSION_yesod_form(1,3,9)+f1 = "f1"+f2 = "f2"+#else+f1 = "f2"+f2 = "f3"+#endif+ newAccountSpecs :: YesodSpec MyApp newAccountSpecs =     ydescribe "New account tests" $ do@@ -73,7 +88,7 @@             -- resend verify email             post'"/auth/page/account/resendverifyemail" $ do                 addNonce-                addPostParam "f2" "abc" -- username is also a hidden field+                addPostParam f1 "abc" -- username is also a hidden field             statusIs 302             get' "/"             bodyContains "A confirmation e-mail has been sent to test@example.com"@@ -131,24 +146,24 @@                 addNonce                 byLabel "New password" "www"                 byLabel "Confirm" "www"-                addPostParam "f2" "abc"-                addPostParam "f3" "qqqqqqqqqqqqqq"+                addPostParam f1 "abc"+                addPostParam f2 "qqqqqqqqqqqqqq"             statusIs 403             bodyContains "Invalid key"              -- good key             get' newpwd             statusIs 200-            matches <- htmlQuery "input[name=f3][type=hidden][value]"+            matches <- htmlQuery $ "input[name=" <> f2 <> "][type=hidden][value]"             post'"/auth/page/account/setpassword" $ do                 addNonce                 byLabel "New password" "www"                 byLabel "Confirm" "www"-                addPostParam "f2" "abc"+                addPostParam f1 "abc"                 key <- case matches of                           [] -> error "Unable to find set password key"                           element:_ -> return $ head $ attribute "value" $ parseHTML element-                addPostParam "f3" key+                addPostParam f2 key             statusIs 302             get' "/"             statusIs 200
yesod-auth-account.cabal view
@@ -1,5 +1,5 @@ name:              yesod-auth-account-version:           1.2.5+version:           1.2.6 cabal-version:     >= 1.8 build-type:        Simple synopsis:          An account authentication plugin for Yesod