session locking implemented
This commit is contained in:
parent
b27faf2948
commit
a365632363
12
app/Main.hs
12
app/Main.hs
|
@ -61,6 +61,7 @@ mainMenu :: S.StateT Status IO ()
|
||||||
mainMenu = do
|
mainMenu = do
|
||||||
menu "Main Menu"
|
menu "Main Menu"
|
||||||
[ ( "change master password", changeMasterPass )
|
[ ( "change master password", changeMasterPass )
|
||||||
|
, ( "lock session", lockSession )
|
||||||
, ( "quit", quit )
|
, ( "quit", quit )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -71,6 +72,17 @@ changeMasterPass = do
|
||||||
S.modify $ set masterPass newP
|
S.modify $ set masterPass newP
|
||||||
mainMenu
|
mainMenu
|
||||||
|
|
||||||
|
lockSession :: S.StateT Status IO ()
|
||||||
|
lockSession = do
|
||||||
|
lift $ putStrLn "\nsession locked"
|
||||||
|
pass <- S.gets $ view masterPass
|
||||||
|
mx <- lift $ R.runRequest $ R.prompt "password: " $ R.reqPassword
|
||||||
|
case mx of
|
||||||
|
Nothing -> lockSession
|
||||||
|
Just x -> if x == pass
|
||||||
|
then mainMenu
|
||||||
|
else lockSession
|
||||||
|
|
||||||
quit :: S.StateT Status IO ()
|
quit :: S.StateT Status IO ()
|
||||||
quit = return ()
|
quit = return ()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user