From a36563236365d34de07fd262a36380f3889e9446 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sun, 9 Dec 2018 14:31:58 -0500 Subject: [PATCH] session locking implemented --- app/Main.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Main.hs b/app/Main.hs index fb70187..e31ce3d 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -61,6 +61,7 @@ mainMenu :: S.StateT Status IO () mainMenu = do menu "Main Menu" [ ( "change master password", changeMasterPass ) + , ( "lock session", lockSession ) , ( "quit", quit ) ] @@ -71,6 +72,17 @@ changeMasterPass = do S.modify $ set masterPass newP 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 = return ()