Skip to content
Browse files

setPasswordResetToken needs to return the new token

  • Loading branch information...
1 parent f821622 commit bfb7f023afef792b80f27ef27e3e9cb882bed598 @mightybyte mightybyte committed Nov 27, 2012
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
------------------------------------------------------------------------------

0 comments on commit bfb7f02

Please sign in to comment.
Something went wrong with that request. Please try again.