1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00
This commit is contained in:
Jonas Hendrickx 2024-10-30 09:11:22 +01:00
parent 420247a5e4
commit 65bc9bb01f
3 changed files with 86 additions and 52 deletions

View File

@ -1,4 +1,5 @@
using Bit.Admin.AdminConsole.Models;
using System.ComponentModel.DataAnnotations;
using Bit.Admin.AdminConsole.Models;
using Bit.Admin.Enums;
using Bit.Admin.Services;
using Microsoft.AspNetCore.Components;
@ -11,4 +12,29 @@ public partial class Admins(
private readonly bool _canResendEmailInvite = accessControlService.UserHasPermission(Permission.Provider_ResendEmailInvite);
[Parameter] public ProviderViewModel Model { get; set; }
[SupplyParameterFromForm(FormName = "ManageAdminsForm")]
public ManageAdminsFormModel FormModel { get; set; } = new();
[Parameter]
public Guid ProviderId { get; set; }
[Parameter]
public Guid OwnerId { get; set; }
[SupplyParameterFromQuery]
public Guid? InviteResentTo { get; set; }
private async Task OnValidSubmitAsync()
{
await ProviderService.ResendProviderSetupInviteEmailAsync(ProviderId, OwnerId);
var uri = NavigationManager.GetUriWithQueryParameters($"/admin/providers/{ProviderId}/admins", new Dictionary<string, object?> { { "inviteResentTo", OwnerId.ToString() } });
NavigationManager.NavigateTo(uri);
}
public class ManageAdminsFormModel
{
[Required]
public Guid UserId { get; set; }
}
}

View File

@ -1,10 +1,17 @@
@using Bit.Admin.Services
@using Bit.Core.AdminConsole.Enums.Provider
@inject Services.IAccessControlService AccessControlService
@using Bit.Core.AdminConsole.Services
@inject IAccessControlService AccessControlService
@inject IProviderService ProviderService
@inject NavigationManager NavigationManager
<h2>Provider Admins</h2>
<div class="row">
<div class="col-8">
<div class="table-responsive">
<EditForm FormName="ManageAdminsForm" Model="FormModel" OnValidSubmit="OnValidSubmitAsync">
<DataAnnotationsValidator />
<table class="table table-striped table-hover">
<thead>
<tr>
@ -14,7 +21,7 @@
</tr>
</thead>
<tbody>
@if(!Model.ProviderAdmins.Any())
@if (!Model.ProviderAdmins.Any())
{
<tr>
<td colspan="6">No results to list.</td>
@ -22,7 +29,7 @@
}
else
{
@foreach(var admin in Model.ProviderAdmins)
@foreach (var admin in Model.ProviderAdmins)
{
<tr>
<td class="align-middle">
@ -32,23 +39,23 @@
@admin.Status
</td>
<td>
@if(admin.Status.Equals(ProviderUserStatusType.Confirmed)
@if (admin.Status.Equals(ProviderUserStatusType.Confirmed)
&& Model.Provider.Status.Equals(ProviderStatusType.Pending)
&& _canResendEmailInvite)
{
<!--@if(@TempData["InviteResentTo"] != null && @TempData["InviteResentTo"].ToString() == @admin.UserId.Value.ToString())
@if (InviteResentTo == admin.UserId!.Value)
{
<button class="btn btn-outline-success btn-sm disabled" disabled>Invite Resent!</button>
}
else
{
<a class="btn btn-outline-secondary btn-sm"
data-id="@admin.Id" asp-controller="Providers"
asp-action="ResendInvite" asp-route-ownerId="@admin.UserId"
asp-route-providerId="@Model.Provider.Id">
<button class="btn btn-outline-secondary btn-sm"
type="submit"
name="FormModel.UserId"
value="@admin.Id">
Resend Setup Invite
</a>
}-->
</button>
}
}
</td>
</tr>
@ -56,6 +63,7 @@
}
</tbody>
</table>
</EditForm>
</div>
</div>
</div>

View File

@ -13,7 +13,7 @@
<h2>Provider Information</h2>
<ViewInformation Model="@ViewModel" />
<Admins Model="@ViewModel" />
<Admins Model="@ViewModel" ProviderId="@Id" />
<form method="post" id="edit-form">
<div asp-validation-summary="All" class="alert alert-danger"></div>
<input type="hidden" asp-for="Type" readonly>