123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- @page "/account"
- @using HyperCube.Models;
- @using Microsoft.AspNetCore.Identity;
- @inject AuthenticationStateProvider AuthenticationStateProvider
- @inject UserManager<IdentityUser> UserManager;
- @attribute [Authorize]
- <h3>Личный кабинет</h3>
- <EditForm Model="@account">
- <table class="table-bordered" cellspacing="5" cellpadding="5">
- <tbody>
- <tr>
- <td>UUID:</td>
- <td>@account.UUID</td>
- </tr>
- <tr>
- <td>Name:</td>
- <td>@account.Name</td>
- </tr>
- <tr>
- <td>Email:</td>
- <td>@account.Email</td>
- </tr>
- <tr>
- <td>ETH Address:</td>
- <td>@account.eth_address</td>
- </tr>
- <tr>
- <td>Balance:</td>
- <td>@myBalance WEI</td>
- </tr>
- </tbody>
- </table>
- </EditForm>
- @code {
- private AccountModel account = new();
- string myBalance = "";
- protected override async Task OnInitializedAsync()
- {
- account = await GetCurrentAcc();
- if (Blockchain.GetMain() != null)
- myBalance = await account.GetBalance();
- }
- private async Task<AccountModel> GetCurrentAcc()
- {
- AccountModel account = new();
- var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
- var user = authState.User;
- if (user.Identity.IsAuthenticated)
- {
- var currentUser = await UserManager.GetUserAsync(user);
- var acc = AccountModel.Find(currentUser.Id);
- if (acc != null)
- account = acc;
- account.AccRole = Role.User;
- return account;
- }
- return null;
- }
- }
|