reworked password reactivation
This commit is contained in:
parent
fab24614b1
commit
0a253aa955
1 changed files with 9 additions and 8 deletions
|
@ -16,13 +16,11 @@ postReactivateR = do
|
||||||
((result, reactivateWidget), enctype) <- runFormPost reactivateForm
|
((result, reactivateWidget), enctype) <- runFormPost reactivateForm
|
||||||
case result of
|
case result of
|
||||||
FormSuccess temp -> do
|
FormSuccess temp -> do
|
||||||
tempUsers <- runDB $ selectList [UserEmail ==. temp] []
|
users <- runDB $ selectList [UserEmail ==. temp] []
|
||||||
case tempUsers of
|
case null users of
|
||||||
users -> do
|
True -> do
|
||||||
userTokens <- foldM (\userTokens (Entity userId user) -> do
|
userTokens <- foldM (\userTokens (Entity userId user) -> do
|
||||||
token <- liftIO $ generateString
|
token <- liftIO $ generateString
|
||||||
-- aId <- runDB $ insert $ Activator token user
|
|
||||||
-- runDB $ delete userId
|
|
||||||
tId <- runDB $ insert $ Token (encodeUtf8 token) "activate" (Just userId)
|
tId <- runDB $ insert $ Token (encodeUtf8 token) "activate" (Just userId)
|
||||||
return $ (user, token) : userTokens
|
return $ (user, token) : userTokens
|
||||||
) [] users
|
) [] users
|
||||||
|
@ -34,7 +32,7 @@ postReactivateR = do
|
||||||
activateLink <- ($ ActivateR token) <$> getUrlRender
|
activateLink <- ($ ActivateR token) <$> getUrlRender
|
||||||
sendMail (userEmail user) "Reset your password" $
|
sendMail (userEmail user) "Reset your password" $
|
||||||
[shamlet|
|
[shamlet|
|
||||||
<h1>Welcome again to Eidolon
|
<h1>Welcome again to Eidolon #{userName user}
|
||||||
To reset your password visit the following link:
|
To reset your password visit the following link:
|
||||||
<a href="#{activateLink}">#{activateLink}
|
<a href="#{activateLink}">#{activateLink}
|
||||||
|
|
||||||
|
@ -42,11 +40,14 @@ postReactivateR = do
|
||||||
|]
|
|]
|
||||||
return True
|
return True
|
||||||
) True userTokens
|
) 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
|
redirect $ HomeR
|
||||||
[] -> do
|
False -> do
|
||||||
setMessage "No user mith this Email"
|
setMessage "No user mith this Email"
|
||||||
redirect $ LoginR
|
redirect $ LoginR
|
||||||
|
_ -> do
|
||||||
|
setMessage "There is something wrong with your email"
|
||||||
|
redirect $ ReactivateR
|
||||||
|
|
||||||
reactivateForm :: Form Text
|
reactivateForm :: Form Text
|
||||||
reactivateForm = renderDivs $ (\a -> a)
|
reactivateForm = renderDivs $ (\a -> a)
|
||||||
|
|
Loading…
Reference in a new issue