|
@@ -1,4 +1,55 @@
|
|
|
-<sidebar class="profile-info">
|
|
|
+@namespace HyperCube.Models
|
|
|
+@using Microsoft.AspNetCore.Identity;
|
|
|
+@inject AuthenticationStateProvider AuthenticationStateProvider
|
|
|
+@inject UserManager<IdentityUser> UserManager;
|
|
|
+
|
|
|
+@attribute [Authorize]
|
|
|
+@code
|
|
|
+{
|
|
|
+ AccountModel account;
|
|
|
+ List<Role> roles;
|
|
|
+ //string rr = "";
|
|
|
+ //roles = account.roles;
|
|
|
+
|
|
|
+ protected override async Task OnInitializedAsync()
|
|
|
+ {
|
|
|
+ account = await GetCurrentAcc();
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task InitializeAccount()
|
|
|
+ {
|
|
|
+ AccountModel.Current = await GetCurrentAcc();
|
|
|
+ Console.WriteLine("InitializeAccount in Sidebar " + AccountModel.Current.Name);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ account.UUID = currentUser.Id;
|
|
|
+ //account.Name = currentUser.UserName;
|
|
|
+ //account.Email = currentUser.Email;
|
|
|
+
|
|
|
+ var acc = AccountModel.Find(account.UUID);
|
|
|
+ if (acc != null)
|
|
|
+ account = acc;
|
|
|
+ ///tmp
|
|
|
+
|
|
|
+ //account.AccRole = Role.User;
|
|
|
+ account.Name = "test";
|
|
|
+ return account;
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|
|
|
+<sidebar class="profile-info">
|
|
|
<AuthorizeView>
|
|
|
<Authorized>
|
|
|
<img src="https://place-hold.it/150x150" alt="Фото профиля" class="profile-info__img">
|
|
@@ -11,18 +62,27 @@
|
|
|
<div class="profile-info__link">id 00112</div>
|
|
|
</div>
|
|
|
<div class="profile-info__item">
|
|
|
- <a href="Account" class="profile-info__link">
|
|
|
- <img src="img/qual.svg" alt="qual" class="profile-info__link-img">
|
|
|
- Квалификация
|
|
|
- </a>
|
|
|
- <a href="#" class="profile-info__link">
|
|
|
- <img src="img/rating.svg" alt="qual" class="profile-info__link-img">
|
|
|
- Рейтинги
|
|
|
- </a>
|
|
|
+ @if (account.roles.Contains(Role.Initiator))
|
|
|
+ {
|
|
|
+ <a href="Account" class="profile-info__link">
|
|
|
+ <img src="img/qual.svg" alt="qual" class="profile-info__link-img">
|
|
|
+ Квалификация
|
|
|
+
|
|
|
+ </a>}
|
|
|
+ <a href="#" class="profile-info__link">
|
|
|
+ <img src="img/rating.svg" alt="qual" class="profile-info__link-img">
|
|
|
+ Рейтинги
|
|
|
+ @account.roles.Count;
|
|
|
+ @account.Name;
|
|
|
+ </a>
|
|
|
<a href="Wallet" class="profile-info__link">
|
|
|
<img src="img/wallet.svg" alt="qual" class="profile-info__link-img">
|
|
|
Кошелек
|
|
|
</a>
|
|
|
+ <a href="Blockchains" class="profile-info__link">
|
|
|
+ <img src="img/wallet.svg" alt="qual" class="profile-info__link-img">
|
|
|
+ Blockchains
|
|
|
+ </a>
|
|
|
</div>
|
|
|
<div class="profile-info__item">
|
|
|
<a class="profile-info__link">
|