partial implementation of password view/edit
This commit is contained in:
parent
51208d3fe9
commit
00311092d0
28
app/Main.hs
28
app/Main.hs
|
@ -92,6 +92,7 @@ mainMenu :: S.StateT Status IO ()
|
||||||
mainMenu =
|
mainMenu =
|
||||||
menu "Main Menu"
|
menu "Main Menu"
|
||||||
[ ( "add a password", addPassword )
|
[ ( "add a password", addPassword )
|
||||||
|
, ( "view/edit a password", viewEditPass )
|
||||||
, ( "change master password", changeMasterPass )
|
, ( "change master password", changeMasterPass )
|
||||||
, ( "lock session", lockSession )
|
, ( "lock session", lockSession )
|
||||||
, ( "quit", quit )
|
, ( "quit", quit )
|
||||||
|
@ -112,6 +113,33 @@ addPassword' x = do
|
||||||
S.modify $ over database $ pwSetService x d
|
S.modify $ over database $ pwSetService x d
|
||||||
showPass x
|
showPass x
|
||||||
|
|
||||||
|
viewEditPass :: S.StateT Status IO ()
|
||||||
|
viewEditPass = menu "View/Edit Password"
|
||||||
|
[ ( "search servives", searchServ )
|
||||||
|
, ( "list services", listServ )
|
||||||
|
, ( "cancel", mainMenu )
|
||||||
|
]
|
||||||
|
|
||||||
|
searchServ :: S.StateT Status IO ()
|
||||||
|
searchServ = do
|
||||||
|
svc <- req $ prompt "service name: " reqResp
|
||||||
|
db <- S.gets $ view database
|
||||||
|
selectServ $ pwSearch svc db
|
||||||
|
|
||||||
|
listServ :: S.StateT Status IO ()
|
||||||
|
listServ = S.gets (view database) >>= selectServ . pwSearch ""
|
||||||
|
|
||||||
|
selectServ :: [String] -> S.StateT Status IO ()
|
||||||
|
selectServ xs = menu "Select Service" $
|
||||||
|
("cancel", mainMenu) :
|
||||||
|
map (\x -> (x, viewEdit x)) xs
|
||||||
|
|
||||||
|
viewEdit :: String -> S.StateT Status IO ()
|
||||||
|
viewEdit x = menu x
|
||||||
|
[ ( "show password", showPass x >> viewEdit x )
|
||||||
|
, ( "cancel", mainMenu )
|
||||||
|
]
|
||||||
|
|
||||||
changeMasterPass :: S.StateT Status IO ()
|
changeMasterPass :: S.StateT Status IO ()
|
||||||
changeMasterPass = do
|
changeMasterPass = do
|
||||||
oldP <- S.gets $ view masterPass
|
oldP <- S.gets $ view masterPass
|
||||||
|
|
|
@ -43,7 +43,7 @@ module Password (
|
||||||
-- ** Password Checkers
|
-- ** Password Checkers
|
||||||
pwCountUpper, pwCountLower, pwCountDigits, pwCountSpecial,
|
pwCountUpper, pwCountLower, pwCountDigits, pwCountSpecial,
|
||||||
-- ** Database Functions
|
-- ** Database Functions
|
||||||
pwHasService, pwSetService, pwGetService
|
pwHasService, pwSetService, pwGetService, pwSearch
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens (makeLenses, over, set, (^.))
|
import Control.Lens (makeLenses, over, set, (^.))
|
||||||
|
@ -238,6 +238,16 @@ pwGetService
|
||||||
-- not found
|
-- not found
|
||||||
pwGetService = M.lookup
|
pwGetService = M.lookup
|
||||||
|
|
||||||
|
-- | searches for a service
|
||||||
|
pwSearch
|
||||||
|
:: String
|
||||||
|
-- ^ the search string
|
||||||
|
-> PWDatabase
|
||||||
|
-- ^ the database to search
|
||||||
|
-> [String]
|
||||||
|
-- ^ the matching service names
|
||||||
|
pwSearch = undefined
|
||||||
|
|
||||||
isSpecial :: Char -> Bool
|
isSpecial :: Char -> Bool
|
||||||
isSpecial x = not $ isUpper x || isLower x || isDigit x
|
isSpecial x = not $ isUpper x || isLower x || isDigit x
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user