Merge branch 'master' of github.com:yesodweb/yesod
This commit is contained in:
commit
f72f3fa058
@ -1,5 +1,8 @@
|
|||||||
# ChangeLog for yesod-auth
|
# ChangeLog for yesod-auth
|
||||||
|
|
||||||
|
## 1.6.4.1
|
||||||
|
* Email: Fix forgot-password endpoint [#1537](https://github.com/yesodweb/yesod/pull/1537)
|
||||||
|
|
||||||
## 1.6.4
|
## 1.6.4
|
||||||
|
|
||||||
* Make `registerHelper` configurable [#1524](https://github.com/yesodweb/yesod/issues/1524)
|
* Make `registerHelper` configurable [#1524](https://github.com/yesodweb/yesod/issues/1524)
|
||||||
|
|||||||
@ -195,9 +195,11 @@ class ( YesodAuth site
|
|||||||
-- @since 1.1.0
|
-- @since 1.1.0
|
||||||
addUnverified :: Email -> VerKey -> AuthHandler site (AuthEmailId site)
|
addUnverified :: Email -> VerKey -> AuthHandler site (AuthEmailId site)
|
||||||
|
|
||||||
-- | Similar to `addUnverified`, but comes with the registered password
|
-- | Similar to `addUnverified`, but comes with the registered password.
|
||||||
-- the default implementation is just `addUnverified`, which ignores the password
|
--
|
||||||
-- you may override this to save the salted password to your database
|
-- The default implementation is just `addUnverified`, which ignores the password.
|
||||||
|
--
|
||||||
|
-- You may override this to save the salted password to your database.
|
||||||
--
|
--
|
||||||
-- @since 1.6.4
|
-- @since 1.6.4
|
||||||
addUnverifiedWithPass :: Email -> VerKey -> SaltedPass -> AuthHandler site (AuthEmailId site)
|
addUnverifiedWithPass :: Email -> VerKey -> SaltedPass -> AuthHandler site (AuthEmailId site)
|
||||||
@ -516,10 +518,10 @@ parseRegister = withObject "email" (\obj -> do
|
|||||||
|
|
||||||
registerHelper :: YesodAuthEmail master
|
registerHelper :: YesodAuthEmail master
|
||||||
=> Bool -- ^ allow usernames?
|
=> Bool -- ^ allow usernames?
|
||||||
-> Bool -- ^ allow password?
|
-> Bool -- ^ forgot password?
|
||||||
-> Route Auth
|
-> Route Auth
|
||||||
-> AuthHandler master TypedContent
|
-> AuthHandler master TypedContent
|
||||||
registerHelper allowUsername allowPassword dest = do
|
registerHelper allowUsername forgotPassword dest = do
|
||||||
y <- getYesod
|
y <- getYesod
|
||||||
checkCsrfHeaderOrParam defaultCsrfHeaderName defaultCsrfParamName
|
checkCsrfHeaderOrParam defaultCsrfHeaderName defaultCsrfParamName
|
||||||
result <- runInputPostResult $ (,)
|
result <- runInputPostResult $ (,)
|
||||||
@ -542,8 +544,8 @@ registerHelper allowUsername allowPassword dest = do
|
|||||||
| allowUsername -> Right $ TS.strip x
|
| allowUsername -> Right $ TS.strip x
|
||||||
| otherwise -> Left Msg.InvalidEmailAddress
|
| otherwise -> Left Msg.InvalidEmailAddress
|
||||||
|
|
||||||
let mpass = case (allowPassword, creds) of
|
let mpass = case (forgotPassword, creds) of
|
||||||
(True, Just (_, mp)) -> mp
|
(False, Just (_, mp)) -> mp
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
case eidentifier of
|
case eidentifier of
|
||||||
@ -571,9 +573,10 @@ registerHelper allowUsername allowPassword dest = do
|
|||||||
Nothing -> loginErrorMessageI dest (Msg.IdentifierNotFound identifier)
|
Nothing -> loginErrorMessageI dest (Msg.IdentifierNotFound identifier)
|
||||||
Just creds@(_, False, _, _) -> sendConfirmationEmail creds
|
Just creds@(_, False, _, _) -> sendConfirmationEmail creds
|
||||||
Just creds@(_, True, _, _) -> do
|
Just creds@(_, True, _, _) -> do
|
||||||
case emailPreviouslyRegisteredResponse identifier of
|
if forgotPassword then sendConfirmationEmail creds
|
||||||
Just response -> response
|
else case emailPreviouslyRegisteredResponse identifier of
|
||||||
Nothing -> sendConfirmationEmail creds
|
Just response -> response
|
||||||
|
Nothing -> sendConfirmationEmail creds
|
||||||
where sendConfirmationEmail (lid, _, verKey, email) = do
|
where sendConfirmationEmail (lid, _, verKey, email) = do
|
||||||
render <- getUrlRender
|
render <- getUrlRender
|
||||||
tp <- getRouteToParent
|
tp <- getRouteToParent
|
||||||
@ -583,7 +586,7 @@ registerHelper allowUsername allowPassword dest = do
|
|||||||
|
|
||||||
|
|
||||||
postRegisterR :: YesodAuthEmail master => AuthHandler master TypedContent
|
postRegisterR :: YesodAuthEmail master => AuthHandler master TypedContent
|
||||||
postRegisterR = registerHelper False True registerR
|
postRegisterR = registerHelper False False registerR
|
||||||
|
|
||||||
getForgotPasswordR :: YesodAuthEmail master => AuthHandler master Html
|
getForgotPasswordR :: YesodAuthEmail master => AuthHandler master Html
|
||||||
getForgotPasswordR = forgotPasswordHandler
|
getForgotPasswordR = forgotPasswordHandler
|
||||||
@ -627,7 +630,7 @@ defaultForgotPasswordHandler = do
|
|||||||
}
|
}
|
||||||
|
|
||||||
postForgotPasswordR :: YesodAuthEmail master => AuthHandler master TypedContent
|
postForgotPasswordR :: YesodAuthEmail master => AuthHandler master TypedContent
|
||||||
postForgotPasswordR = registerHelper True False forgotPasswordR
|
postForgotPasswordR = registerHelper True True forgotPasswordR
|
||||||
|
|
||||||
getVerifyR :: YesodAuthEmail site
|
getVerifyR :: YesodAuthEmail site
|
||||||
=> AuthEmailId site
|
=> AuthEmailId site
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-auth
|
name: yesod-auth
|
||||||
version: 1.6.4
|
version: 1.6.4.1
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman, Patrick Brisbin
|
author: Michael Snoyman, Patrick Brisbin
|
||||||
|
|||||||
@ -103,7 +103,7 @@ to jump through the hoops implied above.
|
|||||||
|
|
||||||
One important note: I highly recommend putting _all_ of the logic in
|
One important note: I highly recommend putting _all_ of the logic in
|
||||||
your library, and then providing a `develMain :: IO ()` function which
|
your library, and then providing a `develMain :: IO ()` function which
|
||||||
yoru `app/devel.hs` script reexports as `main`. I've found this to
|
your `app/devel.hs` script reexports as `main`. I've found this to
|
||||||
greatly simplify things overall, since you can ensure all of your
|
greatly simplify things overall, since you can ensure all of your
|
||||||
dependencies are specified correctly in your `.cabal` file. Also, I
|
dependencies are specified correctly in your `.cabal` file. Also, I
|
||||||
recommend using `PackageImports` in that file, as the example app
|
recommend using `PackageImports` in that file, as the example app
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user