reordered functions in UI module
This commit is contained in:
parent
318079dca8
commit
0920bff2f5
66
app/UI.hs
66
app/UI.hs
|
@ -88,6 +88,39 @@ viewEditMenu = menu "View/Edit Password"
|
||||||
, ( "cancel", mainMenu )
|
, ( "cancel", mainMenu )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
changeMasterPass :: S.StateT Status IO ()
|
||||||
|
changeMasterPass = do
|
||||||
|
oldP <- S.gets $ view masterPass
|
||||||
|
newP <- req $ reqDefault getMasterPass oldP
|
||||||
|
S.modify $ set masterPass newP
|
||||||
|
mainMenu
|
||||||
|
|
||||||
|
lockSession :: S.StateT Status IO ()
|
||||||
|
lockSession = do
|
||||||
|
lift $ putStrLn "\nsession locked"
|
||||||
|
pass <- S.gets $ view masterPass
|
||||||
|
mx <- lift $ runRequest $ prompt "password: " reqPassword
|
||||||
|
case mx of
|
||||||
|
Nothing -> lockSession
|
||||||
|
Just x -> if x == pass
|
||||||
|
then mainMenu
|
||||||
|
else lockSession
|
||||||
|
|
||||||
|
quit :: S.StateT Status IO ()
|
||||||
|
quit = return ()
|
||||||
|
|
||||||
|
buildData :: S.StateT Status IO PWData
|
||||||
|
buildData = do
|
||||||
|
d <- run newPWData
|
||||||
|
req $ reqIf (confirm "would you like to change the default policy?")
|
||||||
|
(do
|
||||||
|
let p = d^.pwPolicy
|
||||||
|
p <- editPolicy p <|> do
|
||||||
|
reqIO $ putStrLn "invalid password policy - using default"
|
||||||
|
return p
|
||||||
|
return $ set pwPolicy p d)
|
||||||
|
(return d)
|
||||||
|
|
||||||
searchServ :: S.StateT Status IO ()
|
searchServ :: S.StateT Status IO ()
|
||||||
searchServ = do
|
searchServ = do
|
||||||
svc <- req $ prompt "service name: " reqResp
|
svc <- req $ prompt "service name: " reqResp
|
||||||
|
@ -132,27 +165,6 @@ changeSalt x = do
|
||||||
showPass x
|
showPass x
|
||||||
servMenu x
|
servMenu x
|
||||||
|
|
||||||
changeMasterPass :: S.StateT Status IO ()
|
|
||||||
changeMasterPass = do
|
|
||||||
oldP <- S.gets $ view masterPass
|
|
||||||
newP <- req $ reqDefault getMasterPass oldP
|
|
||||||
S.modify $ set masterPass newP
|
|
||||||
mainMenu
|
|
||||||
|
|
||||||
lockSession :: S.StateT Status IO ()
|
|
||||||
lockSession = do
|
|
||||||
lift $ putStrLn "\nsession locked"
|
|
||||||
pass <- S.gets $ view masterPass
|
|
||||||
mx <- lift $ runRequest $ prompt "password: " reqPassword
|
|
||||||
case mx of
|
|
||||||
Nothing -> lockSession
|
|
||||||
Just x -> if x == pass
|
|
||||||
then mainMenu
|
|
||||||
else lockSession
|
|
||||||
|
|
||||||
quit :: S.StateT Status IO ()
|
|
||||||
quit = return ()
|
|
||||||
|
|
||||||
showPass :: String -> S.StateT Status IO ()
|
showPass :: String -> S.StateT Status IO ()
|
||||||
showPass x = do
|
showPass x = do
|
||||||
lift $ putStrLn ""
|
lift $ putStrLn ""
|
||||||
|
@ -165,18 +177,6 @@ showPass x = do
|
||||||
Nothing -> "invalid password data"
|
Nothing -> "invalid password data"
|
||||||
Just pw -> "password for " ++ x ++ ": " ++ pw
|
Just pw -> "password for " ++ x ++ ": " ++ pw
|
||||||
|
|
||||||
buildData :: S.StateT Status IO PWData
|
|
||||||
buildData = do
|
|
||||||
d <- run newPWData
|
|
||||||
req $ reqIf (confirm "would you like to change the default policy?")
|
|
||||||
(do
|
|
||||||
let p = d^.pwPolicy
|
|
||||||
p <- editPolicy p <|> do
|
|
||||||
reqIO $ putStrLn "invalid password policy - using default"
|
|
||||||
return p
|
|
||||||
return $ set pwPolicy p d)
|
|
||||||
(return d)
|
|
||||||
|
|
||||||
-- TODO: refactor this monstrosity
|
-- TODO: refactor this monstrosity
|
||||||
editPolicy :: PWPolicy -> Request PWPolicy
|
editPolicy :: PWPolicy -> Request PWPolicy
|
||||||
editPolicy p = if validatePWPolicy p
|
editPolicy p = if validatePWPolicy p
|
||||||
|
|
Loading…
Reference in New Issue
Block a user