Fix PIN generator
This commit is contained in:
parent
625fdcaee8
commit
e9085d6b9e
3 changed files with 5 additions and 4 deletions
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the PIN generation
|
||||||
- Fixed calculation of order total to ensure 8 decimal places
|
- Fixed calculation of order total to ensure 8 decimal places
|
||||||
- Fixed test for looking for an order with incorrect ID
|
- Fixed test for looking for an order with incorrect ID
|
||||||
- Fixed payment scan to focus only on new transactions
|
- Fixed payment scan to focus only on new transactions
|
||||||
|
|
|
@ -99,9 +99,9 @@ validateUser session =
|
||||||
(select ["session" =: session] "users")
|
(select ["session" =: session] "users")
|
||||||
["$set" =: ["validated" =: True]]
|
["$set" =: ["validated" =: True]]
|
||||||
|
|
||||||
generatePin :: IO T.Text
|
generatePin :: Int -> IO T.Text
|
||||||
generatePin = do
|
generatePin s = do
|
||||||
g <- newStdGen
|
let g = mkStdGen s
|
||||||
pure $
|
pure $
|
||||||
T.pack (padLeft (show . head $ randomRs (1 :: Integer, 10000000) g) '0' 7)
|
T.pack (padLeft (show . head $ randomRs (1 :: Integer, 10000000) g) '0' 7)
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ addUser _ _ _ _ _ Nothing = return () --`debug` "addUser got Nothing"
|
||||||
addUser nodeUser nodePwd p db node (Just tx) = do
|
addUser nodeUser nodePwd p db node (Just tx) = do
|
||||||
isNew <- liftIO $ isUserNew p db tx
|
isNew <- liftIO $ isUserNew p db tx
|
||||||
when isNew $ do
|
when isNew $ do
|
||||||
let newPin = unsafePerformIO generatePin
|
let newPin = unsafePerformIO (generatePin (fromIntegral $ blocktime tx))
|
||||||
_ <- sendPin nodeUser nodePwd node (address tx) newPin
|
_ <- sendPin nodeUser nodePwd node (address tx) newPin
|
||||||
insert_
|
insert_
|
||||||
"users"
|
"users"
|
||||||
|
|
Loading…
Reference in a new issue