123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- @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">
- <div class="profile-info__list">
- <div class="profile-info__item">
- <div class="profile-info__link">Имя: @context.User.Identity.Name</div>
- <div class="profile-info__link">Фамилия: @context.User.Identity.Name</div>
- </div>
- <div class="profile-info__item">
- <div class="profile-info__link">id 00112</div>
- </div>
- <div class="profile-info__item">
- @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">
- <img src="img/exit.svg" alt="qual" class="profile-info__link-img">
- <form method="post" action="Identity/Account/LogOut">
- <button type="submit" class="nav-link btn btn-link">Выйти</button>
- </form>
- </a>
- </div>
- </div>
- </Authorized>
- <NotAuthorized>
- <a class="profile-info__link" href="Identity/Account/Register">Регистрация</a>
- <a class="profile-info__link" href="Identity/Account/Login">Вход</a>
- </NotAuthorized>
- </AuthorizeView>
- </sidebar>
|