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