confirm master password before creating new service
This commit is contained in:
parent
927ce27865
commit
a615538d96
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
- refactoring
|
- refactoring
|
||||||
- store the database where Windows can find it
|
- store the database where Windows can find it
|
||||||
|
- confirm master password before creating new service
|
||||||
|
|
||||||
## 0.2
|
## 0.2
|
||||||
|
|
||||||
|
|
17
app/UI.hs
17
app/UI.hs
|
@ -20,6 +20,8 @@ License along with this program. If not, see
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
module UI (getMasterPass, mainMenu) where
|
module UI (getMasterPass, mainMenu) where
|
||||||
|
|
||||||
import Control.Lens (over, set, view, (^.))
|
import Control.Lens (over, set, view, (^.))
|
||||||
|
@ -37,6 +39,7 @@ import System.Console.HCL
|
||||||
, reqPassword
|
, reqPassword
|
||||||
, reqResp
|
, reqResp
|
||||||
, required
|
, required
|
||||||
|
, runRequest
|
||||||
)
|
)
|
||||||
|
|
||||||
import Password
|
import Password
|
||||||
|
@ -67,6 +70,20 @@ mainMenu =
|
||||||
|
|
||||||
addPassword :: S.StateT Status IO ()
|
addPassword :: S.StateT Status IO ()
|
||||||
addPassword = do
|
addPassword = do
|
||||||
|
pass <- S.gets (^.masterPass)
|
||||||
|
|
||||||
|
lift (runRequest $ prompt "confirm master password: " reqPassword)
|
||||||
|
>>= \case
|
||||||
|
Nothing -> mainMenu
|
||||||
|
Just chkPass
|
||||||
|
| pass == chkPass -> addPassword'
|
||||||
|
|
||||||
|
| otherwise -> do
|
||||||
|
lift $ putStrLn "Incorrect master password."
|
||||||
|
mainMenu
|
||||||
|
|
||||||
|
addPassword' :: S.StateT Status IO ()
|
||||||
|
addPassword' = do
|
||||||
svc <- req $ prompt "service name: " reqResp
|
svc <- req $ prompt "service name: " reqResp
|
||||||
ifServExists svc
|
ifServExists svc
|
||||||
(do
|
(do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user