properly mask the ServerAPIToken in the web interface

This commit is contained in:
JackTerok 2021-02-19 16:20:03 +01:00
parent 674862eff9
commit a572436c8a
2 changed files with 20 additions and 1 deletions

View File

@ -83,6 +83,25 @@ namespace Core.Main
return result;
}
public string GetProfitTrailerServerAPITokenMasked()
{
string result = "";
if (!this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Equals(""))
{
result = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(0, 4);
for (int i = 1; i < this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length - 8; i++)
{
result += "*";
}
result += this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length - 4);
}
return result;
}
public GeneralSettings GeneralSettings
{
get

View File

@ -92,7 +92,7 @@
<div class="form-group row">
<label class="col-md-4 col-form-label">Profit Trailer Server API Token <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The API token needed to communicate with Profit Trailer - set in Profit Trailer Server Settings"></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="Application_ProfitTrailerServerAPIToken" value="@Model.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken">
@Model.PTMagicConfiguration.GetProfitTrailerServerAPITokenMasked()
</div>
</div>