fixed nextPolicy
This commit is contained in:
parent
648e166110
commit
bbf80b87ec
|
@ -44,7 +44,7 @@ module Password (
|
||||||
pwCountUpper, pwCountLower, pwCountDigits, pwCountSpecial
|
pwCountUpper, pwCountLower, pwCountDigits, pwCountSpecial
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens (makeLenses, over, (^.))
|
import Control.Lens (makeLenses, over, set, (^.))
|
||||||
import Data.Char (isUpper, isLower, isDigit, isAlphaNum)
|
import Data.Char (isUpper, isLower, isDigit, isAlphaNum)
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
@ -220,12 +220,17 @@ mkHash = undefined
|
||||||
|
|
||||||
nextPolicy :: Char -> PWPolicy -> PWPolicy
|
nextPolicy :: Char -> PWPolicy -> PWPolicy
|
||||||
nextPolicy x p = over pwLength pred $
|
nextPolicy x p = over pwLength pred $
|
||||||
over lens pred p where
|
if isUpper x
|
||||||
lens
|
then dec pwUpper
|
||||||
| isUpper x = pwUpper
|
else if isLower x
|
||||||
| isLower x = pwLower
|
then dec pwLower
|
||||||
| isDigit x = pwDigits
|
else if isDigit x
|
||||||
| otherwise = pwSpecial . traverse
|
then dec pwDigits
|
||||||
|
else case p^.pwSpecial of
|
||||||
|
Nothing -> set pwSpecial (Just (-1)) p
|
||||||
|
Just x -> set pwSpecial (Just $ pred x) p
|
||||||
|
where
|
||||||
|
dec l = over l (max 0 . pred) p
|
||||||
|
|
||||||
toUTF8 :: String -> B.ByteString
|
toUTF8 :: String -> B.ByteString
|
||||||
toUTF8 = undefined
|
toUTF8 = undefined
|
||||||
|
|
Loading…
Reference in New Issue
Block a user