Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

setPasswordResetToken needs to return the new token

  • Loading branch information...
commit bfb7f023afef792b80f27ef27e3e9cb882bed598 1 parent f821622
@mightybyte mightybyte authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/Snap/Snaplet/Auth/Handlers.hs
View
8 src/Snap/Snaplet/Auth/Handlers.hs
@@ -504,11 +504,13 @@ withBackend f = join $ do
-- password. Then use the token to autogenerate a link that the user can
-- visit to reset their password. This function also sets a timestamp so the
-- reset token can be expired.
-setPasswordResetToken :: Text -> Handler b (AuthManager b) Bool
+setPasswordResetToken :: Text -> Handler b (AuthManager b) (Maybe Text)
setPasswordResetToken login = do
- token <- liftIO . randomToken 40 =<< gets randomNumberGenerator
+ tokBS <- liftIO . randomToken 40 =<< gets randomNumberGenerator
+ let token = decodeUtf8 tokBS
now <- liftIO getCurrentTime
- modPasswordResetToken login (Just $ decodeUtf8 token) (Just now)
+ success <- modPasswordResetToken login (Just token) (Just now)
+ return $ if success then Just token else Nothing
------------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.