mirror of
https://github.com/bitwarden/server
synced 2026-01-10 04:23:31 +00:00
some helper functions for users and orgs
This commit is contained in:
@@ -3,6 +3,57 @@
|
||||
ViewData["Title"] = "User Edit: " + Model.User.Email;
|
||||
}
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
(function() {
|
||||
document.getElementById('upgrade-premium').addEventListener('click', function () {
|
||||
if (document.getElementById('@(nameof(Model.Premium))').checked) {
|
||||
alert('User is already premium.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Premium
|
||||
document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1';
|
||||
document.getElementById('@(nameof(Model.Premium))').checked = true;
|
||||
// Licensing
|
||||
document.getElementById('@(nameof(Model.LicenseKey))').value = '@Model.RandomLicenseKey';
|
||||
document.getElementById('@(nameof(Model.PremiumExpirationDate))').value =
|
||||
'@Model.OneYearExpirationDate';
|
||||
});
|
||||
|
||||
document.getElementById('gateway-customer-link').addEventListener('click', function () {
|
||||
var gateway = document.getElementById('@(nameof(Model.Gateway))');
|
||||
var customerId = document.getElementById('@(nameof(Model.GatewayCustomerId))');
|
||||
if (!gateway || gateway.value === '' || !customerId || customerId.value === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gateway.value === '@((byte)Bit.Core.Enums.GatewayType.Stripe)') {
|
||||
window.open('https://dashboard.stripe.com/customers/' + customerId.value, '_blank');
|
||||
} else if (gateway.value === '@((byte)Bit.Core.Enums.GatewayType.Braintree)') {
|
||||
window.open('https://www.braintreegateway.com/merchants/@(Model.BraintreeMerchantId)/'
|
||||
+ customerId.value, '_blank');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('gateway-subscription-link').addEventListener('click', function () {
|
||||
var gateway = document.getElementById('@(nameof(Model.Gateway))');
|
||||
var subId = document.getElementById('@(nameof(Model.GatewaySubscriptionId))');
|
||||
if (!gateway || gateway.value === '' || !subId || subId.value === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gateway.value === '@((byte)Bit.Core.Enums.GatewayType.Stripe)') {
|
||||
window.open('https://dashboard.stripe.com/subscriptions/' + subId.value, '_blank');
|
||||
} else if (gateway.value === '@((byte)Bit.Core.Enums.GatewayType.Braintree)') {
|
||||
window.open('https://www.braintreegateway.com/merchants/@(Model.BraintreeMerchantId)/' +
|
||||
'subscriptions/' + subId.value, '_blank');
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
}
|
||||
|
||||
<h1>Edit User <small>@Model.User.Email</small></h1>
|
||||
|
||||
<form method="post">
|
||||
@@ -69,21 +120,40 @@
|
||||
<div class="col-sm">
|
||||
<div class="form-group">
|
||||
<label asp-for="GatewayCustomerId"></label>
|
||||
<input type="text" class="form-control" asp-for="GatewayCustomerId">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" asp-for="GatewayCustomerId">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" id="gateway-customer-link">
|
||||
<i class="fa fa-external-link"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="form-group">
|
||||
<label asp-for="GatewaySubscriptionId"></label>
|
||||
<input type="text" class="form-control" asp-for="GatewaySubscriptionId">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" asp-for="GatewaySubscriptionId">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" id="gateway-subscription-link">
|
||||
<i class="fa fa-external-link"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex mt-4">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
<a class="btn btn-danger ml-auto" asp-action="Delete" asp-route-id="@Model.User.Id"
|
||||
onclick="return confirm('Are you sure you want to delete this user (@Model.User.Email)?')">
|
||||
Delete
|
||||
</a>
|
||||
<div class="ml-auto d-flex">
|
||||
<button class="btn btn-secondary mr-2" type="button" id="upgrade-premium">
|
||||
Upgrade Premium
|
||||
</button>
|
||||
<a class="btn btn-danger ml-auto" asp-action="Delete" asp-route-id="@Model.User.Id"
|
||||
onclick="return confirm('Are you sure you want to delete this user (@Model.User.Email)?')">
|
||||
Delete
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user