btcpayserver/BTCPayServer/Views/UIManage/Index.cshtml
d11n bf66b54c9a
User: Add name and image URL (#6008)
* User: Add name and image URL

More personalization options, prerequisite for btcpayserver/app#3.

Additionally:
- Remove ambigious and read-only username from manage view.
- Improve email verification conditions and display.
- Greenfield: Update current user. Prerequisite for btcpayserver/app#13.

* Refactor UpdateCurrentUser

* Replace new columns by UserBlob

* Update email check and add test case for mailbox addresses

---------

Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
2024-06-26 17:39:22 +09:00

81 lines
3.8 KiB
Text

@using BTCPayServer.Abstractions.Contracts
@using BTCPayServer.Abstractions.Models
@using Microsoft.AspNetCore.Mvc.TagHelpers
@inject IFileService FileService
@model IndexViewModel
@{
ViewData.SetActivePage(ManageNavPages.Index, "Update your account");
var canUpload = await FileService.IsAvailable();
}
<form method="post" enctype="multipart/form-data">
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<button type="submit" id="save" class="btn btn-primary">Save</button>
</div>
<partial name="_StatusMessage" />
<div class="col-xxl-constrain col-xl-8">
@if (!ViewContext.ModelState.IsValid)
{
<div asp-validation-summary="All" class="@(ViewContext.ModelState.ErrorCount.Equals(1) ? "no-marker" : "")"></div>
}
<div class="form-group">
<div class="d-flex align-items-center justify-content-between gap-3">
<label asp-for="Email" class="form-label"></label>
@if (Model.RequiresEmailConfirmation)
{
<button asp-action="SendVerificationEmail" class="d-inline-flex align-items-center gap-1 btn btn-link p-0">
<vc:icon symbol="actions-email" />
Send verification email
</button>
}
else if (Model.EmailConfirmed)
{
<span class="d-inline-flex align-items-center gap-1 text-success">
<vc:icon symbol="checkmark" />
confirmed
</span>
}
</div>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Name" class="form-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
@if (canUpload)
{
<div class="form-group">
<div class="d-flex align-items-center justify-content-between gap-2">
<label asp-for="ImageFile" class="form-label"></label>
@if (!string.IsNullOrEmpty(Model.ImageUrl))
{
<button type="submit" class="btn btn-link p-0 text-danger" name="RemoveImageFile" value="true">
<vc:icon symbol="cross" /> Remove
</button>
}
</div>
<div class="d-flex align-items-center gap-3">
<input asp-for="ImageFile" type="file" class="form-control flex-grow">
@if (!string.IsNullOrEmpty(Model.ImageUrl))
{
<img src="@Model.ImageUrl" alt="Profile picture" class="profile-picture"/>
}
</div>
<span asp-validation-for="ImageFile" class="text-danger"></span>
</div>
}
<h3 class="mt-5 mb-4">Delete Account</h3>
<div id="danger-zone">
<a id="delete-user" class="btn btn-outline-danger mb-5" data-confirm-input="DELETE" data-bs-toggle="modal" data-bs-target="#ConfirmModal" asp-action="DeleteUserPost" data-description="This action will also delete all stores, invoices, apps and data associated with the user.">Delete Account</a>
</div>
</div>
</form>
<partial name="_Confirm"
model="@(new ConfirmModel("Delete user", "The user will be permanently deleted. This action will also delete all stores, invoices, apps and data associated with your user.", "Delete", actionName: nameof(BTCPayServer.Controllers.UIManageController.DeleteUserPost)))"/>
@section PageFootContent {
<partial name="_ValidationScriptsPartial"/>
}