In server-initiated situation, the server can set the label

This commit is contained in:
nicolas.dorier 2017-10-18 18:43:52 +09:00
parent 06a96e8b77
commit 94e9ab7f67
5 changed files with 13 additions and 3 deletions

View File

@ -58,6 +58,12 @@ namespace BTCPayServer.Controllers
pairingEntity = await _TokenRepository.GetPairingAsync(request.PairingCode);
pairingEntity.SIN = sin;
if(string.IsNullOrEmpty(pairingEntity.Label) && !string.IsNullOrEmpty(request.Label))
{
pairingEntity.Label = request.Label;
await _TokenRepository.UpdatePairingCode(pairingEntity);
}
var result = await _TokenRepository.PairWithSINAsync(request.PairingCode, sin);
if(result != PairingResult.Complete && result != PairingResult.Partial)
throw new BitpayHttpException(400, $"Error while pairing ({result})");

View File

@ -230,7 +230,7 @@ namespace BTCPayServer.Controllers
{
return View(model);
}
model.Label = model.Label ?? String.Empty;
if(storeId == null) // Permissions are not checked by Policy if the storeId is not passed by url
{
storeId = model.StoreId;

View File

@ -15,7 +15,7 @@ namespace BTCPayServer.Models.StoreViewModels
{
get; set;
}
[Required]
public string Label
{
get; set;

View File

@ -14,6 +14,10 @@
<form method="post">
<div class="form-group">
<label asp-for="Label"></label>
@if(ViewBag.HidePublicKey)
{
<small class="text-muted">optional</small>
}
<input asp-for="Label" class="form-control" />
<span asp-validation-for="Label" class="text-danger"></span>
</div>