on master help sign in
Merge pull request #130 from ilyakooo0/develop
e61fa91iko
denis/src/Data/Query.hs+2−1
@@ -722,7 +722,8 @@ getVerifiedTokenQ :: Query Schema (TuplePG (UserId, ByteString)) (RowPG Token)
722getVerifiedTokenQ = selectStar (from (table #tokens) &
722getVerifiedTokenQ = selectStar (from (table #tokens) &
723 where_ (#tokenUserId .== param @1 .&&
723 where_ (#tokenUserId .== param @1 .&&
724 #tokenValue .== param @2 .&&
724 #tokenValue .== param @2 .&&
725− isNull #tokenVerificationCode))
725+ isNull #tokenVerificationCode .&&
726+ currentTimestamp .< #tokenExpiryDate))
726
727
727-- MARK: FrontEnd Data Structures
728-- MARK: FrontEnd Data Structures
728
729
denis/src/Server/Auth/Token.hs+1−1
@@ -63,7 +63,7 @@ generateTokenM = do
63 activationToken <- randomBytes 64
63 activationToken <- randomBytes 64
64 deactivationToken <- randomBytes 64
64 deactivationToken <- randomBytes 64
65 code <- randomR (0, 999999)
65 code <- randomR (0, 999999)
66− expire <- liftIO $ fmap (addUTCTime (nominalDay * 365)) getCurrentTime -- one year
66+ expire <- liftIO $ fmap (addUTCTime (60*30 {- 30 minutes -} {- nominalDay * 365 -})) getCurrentTime -- one year
67 return $ \ uId ua -> GeneratedToken {
67 return $ \ uId ua -> GeneratedToken {
68 generatedToken = Token uId (hash token) expire (Just . hashVerificationCode $ code) 10 ua (Just . hash $ activationToken) (hash deactivationToken),
68 generatedToken = Token uId (hash token) expire (Just . hashVerificationCode $ code) 10 ua (Just . hash $ activationToken) (hash deactivationToken),
69 generatedTokenValue = token,
69 generatedTokenValue = token,