From 0a253aa9559e48ca4b90ba7a30608827bd7c9541 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 8 Dec 2014 06:14:26 +0100 Subject: [PATCH] reworked password reactivation --- Handler/Reactivate.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Handler/Reactivate.hs b/Handler/Reactivate.hs index 09738cd..0eaab58 100644 --- a/Handler/Reactivate.hs +++ b/Handler/Reactivate.hs @@ -16,13 +16,11 @@ postReactivateR = do ((result, reactivateWidget), enctype) <- runFormPost reactivateForm case result of FormSuccess temp -> do - tempUsers <- runDB $ selectList [UserEmail ==. temp] [] - case tempUsers of - users -> do + users <- runDB $ selectList [UserEmail ==. temp] [] + case null users of + True -> do userTokens <- foldM (\userTokens (Entity userId user) -> do token <- liftIO $ generateString --- aId <- runDB $ insert $ Activator token user --- runDB $ delete userId tId <- runDB $ insert $ Token (encodeUtf8 token) "activate" (Just userId) return $ (user, token) : userTokens ) [] users @@ -34,7 +32,7 @@ postReactivateR = do activateLink <- ($ ActivateR token) <$> getUrlRender sendMail (userEmail user) "Reset your password" $ [shamlet| -

Welcome again to Eidolon +

Welcome again to Eidolon #{userName user} To reset your password visit the following link: #{activateLink} @@ -42,11 +40,14 @@ postReactivateR = do |] return True ) True userTokens - setMessage "Your new passwort will arrive in your e-mail" + setMessage "Your new password activation will arrive in your e-mail" redirect $ HomeR - [] -> do + False -> do setMessage "No user mith this Email" redirect $ LoginR + _ -> do + setMessage "There is something wrong with your email" + redirect $ ReactivateR reactivateForm :: Form Text reactivateForm = renderDivs $ (\a -> a)