allow user to specify temporary alternate master password
This commit is contained in:
parent
258ebf29fe
commit
6585d63385
|
@ -3,6 +3,7 @@
|
|||
## current
|
||||
|
||||
- set maximum version of transformers package
|
||||
- allow user to specifiy a temporary master password to retrieve a password
|
||||
|
||||
## 0.3.0.2
|
||||
|
||||
|
|
18
app/UI.hs
18
app/UI.hs
|
@ -27,7 +27,7 @@ module UI (getMasterPass, mainMenu) where
|
|||
import Control.Monad (when)
|
||||
import Control.Monad.Trans.Class (lift)
|
||||
import qualified Control.Monad.Trans.State as S
|
||||
import Lens.Micro (over, set, (^.))
|
||||
import Lens.Micro (over, set, (^.), (.~))
|
||||
import Lens.Micro.Extras (view)
|
||||
import System.Console.HCL
|
||||
( Request
|
||||
|
@ -162,6 +162,7 @@ selectServ xs = menu "Select Service" $
|
|||
servMenu :: String -> S.StateT Status IO ()
|
||||
servMenu x = menu x
|
||||
[ ( "show password", showPass x >> servMenu x )
|
||||
, ( "show alternate password", showAltPass x )
|
||||
, ( "edit password", editPassMenu x )
|
||||
, ( "remove service", removeServ x )
|
||||
, ( "rename service", renameServ x )
|
||||
|
@ -225,16 +226,25 @@ doEditPolicy x = withService x mainMenu $ \d -> do
|
|||
editPassMenu x
|
||||
|
||||
showPass :: String -> S.StateT Status IO ()
|
||||
showPass x = do
|
||||
lift $ putStrLn ""
|
||||
withService x
|
||||
showPass x = withService x
|
||||
(lift $ putStrLn "The service could not be found in the database.") $
|
||||
\d -> do
|
||||
lift $ putStrLn ""
|
||||
mp <- S.gets $ view masterPass
|
||||
lift $ putStrLn $ case pwGenerate mp d of
|
||||
Nothing -> "The password data were not valid."
|
||||
Just pw -> "password for " ++ x ++ ": " ++ pw
|
||||
|
||||
showAltPass :: String -> S.StateT Status IO ()
|
||||
showAltPass srv = do
|
||||
lift $ putStrLn ""
|
||||
old <- S.gets $ view masterPass
|
||||
Just new <- lift $ runRequest $ required $ prompt "alternate master password: " reqPassword
|
||||
S.modify $ masterPass .~ new
|
||||
showPass srv
|
||||
S.modify $ masterPass .~ old
|
||||
servMenu srv
|
||||
|
||||
-- TODO: refactor this monstrosity
|
||||
editPolicy :: PWPolicy -> Request PWPolicy
|
||||
editPolicy policy = do
|
||||
|
|
Loading…
Reference in New Issue
Block a user