From 333dafece53330b3b6850e7a9128200a97256eea Mon Sep 17 00:00:00 2001 From: Vladislav Yarmak Date: Sun, 8 Oct 2023 12:59:02 +0300 Subject: [PATCH] require login --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 32d0e4d..25d48bf 100644 --- a/main.go +++ b/main.go @@ -194,7 +194,7 @@ func run() int { // Try ressurect state state, err := loadState(args.stateFile) if err != nil { - mainLogger.Warning("Failed to load client state: %v. Performing cold init...", err) + mainLogger.Warning("Failed to load client state: %v. It is OK for a first run. Performing cold init...", err) err = coldInit(wndc, args.username, args.password, args.tfacode, args.timeout) if err != nil { mainLogger.Critical("Cold init failed: %v", err) @@ -376,6 +376,9 @@ func saveState(filename string, state *wndclient.WndClientState) error { } func coldInit(wndc *wndclient.WndClient, username, password, tfacode string, timeout time.Duration) error { + if username == "" || password == "" { + return errors.New(`Please provide "-username" and "-password" command line arguments!`) + } ctx, cl := context.WithTimeout(context.Background(), timeout) err := wndc.Session(ctx, username, password, tfacode) cl()