using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Akari.Prototype.Server.Services; using Spectre.Console; namespace Akari.Prototype.Server.Utils { public static class CliUtils { private const int LoginMaxTries = 3; public static bool Login(IMasterKeyService masterKeyService, IAnsiConsole ansiConsole) { string password; int tries = 0; do { tries++; ansiConsole.WriteLine(); password = ansiConsole.Prompt( new TextPrompt("Enter [yellow]master password[/]") .PromptStyle("red") .Secret() ); } while (!masterKeyService.Login(password) && tries < LoginMaxTries); ansiConsole.WriteLine(); return masterKeyService.IsLoggedIn; } } }