1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-05 23:53:21 +00:00

set environment

This commit is contained in:
Kyle Spearrin
2017-05-16 16:40:31 -04:00
parent fef92f6245
commit 02740d5f86
2 changed files with 63 additions and 3 deletions

View File

@@ -61,7 +61,8 @@ namespace Bit.Console
Con.WriteLine("5. Simulate directory sync");
Con.WriteLine("6. Sync directory");
Con.WriteLine("7. Control background service");
Con.WriteLine("8. Exit");
Con.WriteLine("8. Set environment");
Con.WriteLine("9. Exit");
Con.WriteLine();
Con.Write("What would you like to do? ");
selection = Con.ReadLine();
@@ -105,6 +106,12 @@ namespace Bit.Console
case "service":
await ServiceAsync();
break;
case "8":
case "environnment":
case "env":
await DebugAsync();
break;
case "9":
case "exit":
case "quit":
case "q":
@@ -708,6 +715,7 @@ namespace Bit.Console
try
{
Con.WriteLine("Service current status: {0}", ControllerService.Instance.StatusString);
Con.WriteLine();
}
catch
{
@@ -759,6 +767,7 @@ namespace Bit.Console
}
}
Con.WriteLine();
if(start)
{
Con.WriteLine("Starting service...");
@@ -777,6 +786,57 @@ namespace Bit.Console
return Task.FromResult(0);
}
private static Task DebugAsync()
{
if(_usingArgs)
{
var parameters = ParseParameters();
if(parameters.ContainsKey("debug"))
{
SettingsService.Instance.ApiBaseUrl = "http://localhost:4000";
SettingsService.Instance.IdentityBaseUrl = "http://localhost:33656";
}
else
{
if(parameters.ContainsKey("api"))
{
SettingsService.Instance.ApiBaseUrl = parameters["api"];
}
if(parameters.ContainsKey("id"))
{
SettingsService.Instance.IdentityBaseUrl = parameters["id"];
}
}
}
else
{
var input = string.Empty;
Con.Write("API [{0}]: ", SettingsService.Instance.ApiBaseUrl);
input = Con.ReadLine();
if(input == "debug")
{
SettingsService.Instance.ApiBaseUrl = "http://localhost:4000";
}
else if(!string.IsNullOrEmpty(input))
{
SettingsService.Instance.ApiBaseUrl = input;
}
Con.Write("Identity [{0}]: ", SettingsService.Instance.IdentityBaseUrl);
input = Con.ReadLine();
if(input == "debug")
{
SettingsService.Instance.IdentityBaseUrl = "http://localhost:33656";
}
else if(!string.IsNullOrEmpty(input))
{
SettingsService.Instance.IdentityBaseUrl = input;
}
}
return Task.FromResult(0);
}
private static string ReadSecureLine()
{
var input = string.Empty;

View File

@@ -218,8 +218,8 @@ namespace Bit.Core.Services
public class SettingsModel
{
public string ApiBaseUrl { get; set; }
public string IdentityBaseUrl { get; set; }
public string ApiBaseUrl { get; set; } = "https://api.bitwarden.com";
public string IdentityBaseUrl { get; set; } = "https://identity.bitwarden.com";
public EncryptedData AccessToken { get; set; }
public EncryptedData RefreshToken { get; set; }
public ServerConfiguration Server { get; set; }