protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationAuditService = ScopedServices.GetRequiredService <IWorkstationAuditService>();
                MainTableService        = ScopedServices.GetRequiredService <IMainTableService <WorkstationSession, WorkstationSessionFilter> >();

                switch (DashboardFilter)
                {
                case "NonHideezUnlock":
                    MainTableService.DataLoadingOptions.Filter.UnlockedBy = Hideez.SDK.Communication.SessionSwitchSubject.NonHideez;
                    break;

                case "LongOpenSession":
                    MainTableService.DataLoadingOptions.Filter.Query = WorkstationAuditService.SessionQuery().Where(x => x.StartDate <= DateTime.UtcNow.AddHours(-12) && x.EndDate == null);
                    break;

                case "OpenedSessions":
                    MainTableService.DataLoadingOptions.Filter.Query = WorkstationAuditService.SessionQuery().Where(x => x.EndDate == null);
                    break;
                }

                await BreadcrumbsService.SetAuditWorkstationSessions();

                await MainTableService.InitializeAsync(WorkstationAuditService.GetWorkstationSessionsAsync, WorkstationAuditService.GetWorkstationSessionsCountAsync, ModalDialogService, StateHasChanged, nameof(WorkstationSession.StartDate), ListSortDirection.Descending);

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Beispiel #2
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                DashboardService = ScopedServices.GetRequiredService <IDashboardService>();

                await BreadcrumbsService.SetDashboard();

                ServerdCard = await DashboardService.GetServerCardAsync();

                ServerdCard.RightAction = ShowHardwareVaultTaskAsync;
                if (ServerdCard.Notifications.FirstOrDefault(x => x.Page == "long-pending-tasks") != null)
                {
                    ServerdCard.Notifications.FirstOrDefault(x => x.Page == "long-pending-tasks").Action = ShowHardwareVaultTaskAsync;
                }
                EmployeesCard = await DashboardService.GetEmployeesCardAsync();

                HardwareVaultsCard = await DashboardService.GetHardwareVaultsCardAsync();

                WorkstationsCard = await DashboardService.GetWorkstationsCardAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Beispiel #3
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>();
                RemoteWorkstationConnectionsService = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>();

                Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId);

                if (Workstation == null)
                {
                    throw new Exception("Workstation not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Workstation.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Workstation.Id, Workstation);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #4
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();

                Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                if (Employee == null)
                {
                    throw new HESException(HESCode.EmployeeNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Employee.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Employee.Id, Employee);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #5
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();
                EmailSenderService     = ScopedServices.GetRequiredService <IEmailSenderService>();
                DataTableService       = ScopedServices.GetRequiredService <IDataTableService <ApplicationUser, ApplicationUserFilter> >();

                SynchronizationService.UpdateAdministratorsPage     += UpdateAdministratorsPage;
                SynchronizationService.UpdateAdministratorStatePage += UpdateAdministratorStatePage;

                AuthenticationState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

                await BreadcrumbsService.SetAdministrators();

                await DataTableService.InitializeAsync(ApplicationUserService.GetAdministratorsAsync, ApplicationUserService.GetAdministratorsCountAsync, StateHasChanged, nameof(ApplicationUser.Email), ListSortDirection.Ascending);

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LicenseService       = ScopedServices.GetRequiredService <ILicenseService>();
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                _newLicenseOrder = new NewLicenseOrder()
                {
                    HardwareVaults = await HardwareVaultService.GetVaultsWithoutLicenseAsync()
                };

                _renewLicenseOrder = new RenewLicenseOrder()
                {
                    HardwareVaults = await HardwareVaultService.GetVaultsWithLicenseAsync()
                };

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Beispiel #7
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                TemplateService = ScopedServices.GetRequiredService <ITemplateService>();

                Template = await TemplateService.GetByIdAsync(TemplateId);

                if (Template == null)
                {
                    throw new Exception("Template not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Template.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Template.Id, Template);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Beispiel #8
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LdapService  = ScopedServices.GetRequiredService <ILdapService>();
                GroupService = ScopedServices.GetRequiredService <IGroupService>();

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                if (LdapSettings == null)
                {
                    ActiveDirectoryInitialization = ActiveDirectoryInitialization.HostNotSet;
                }
                else if (LdapSettings?.Host != null && LdapSettings?.UserName == null && LdapSettings?.Password == null)
                {
                    ActiveDirectoryInitialization = ActiveDirectoryInitialization.CredentialsNotSet;
                }
                else
                {
                    await GetGroups(LdapSettings);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Beispiel #9
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                ModalDialogService.OnCancel += OnCancelAsync;

                AccessProfile = await HardwareVaultService.GetProfileByIdAsync(HardwareVaultProfileId);

                if (AccessProfile == null)
                {
                    throw new Exception("Hardware Vault Profile not found.");
                }

                InitPinExpirationValue = AccessProfile.PinExpirationConverted;
                InitPinLengthValue     = AccessProfile.PinLength;
                InitPinTryCountValue   = AccessProfile.PinTryCount;

                EntityBeingEdited = MemoryCache.TryGetValue(AccessProfile.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(AccessProfile.Id, AccessProfile);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                InputType = "Password";

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                Code = await HardwareVaultService.GetVaultActivationCodeAsync(HardwareVault.Id);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Beispiel #11
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService    = ScopedServices.GetRequiredService <IEmployeeService>();
                AppSettingsService = ScopedServices.GetRequiredService <IAppSettingsService>();
                DataTableService   = ScopedServices.GetRequiredService <IDataTableService <Account, AccountFilter> >();
                LdapService        = ScopedServices.GetRequiredService <ILdapService>();

                SynchronizationService.UpdateEmployeeDetailsPage += UpdateEmployeeDetailsPage;
                SynchronizationService.UpdateHardwareVaultState  += UpdateHardwareVaultState;

                await LoadEmployeeAsync();

                await BreadcrumbsService.SetEmployeeDetails(Employee?.FullName);
                await LoadLdapSettingsAsync();

                await DataTableService.InitializeAsync(EmployeeService.GetAccountsAsync, EmployeeService.GetAccountsCountAsync, StateHasChanged, nameof(Account.Name), entityId : EmployeeId);

                await LoadEmployeeSsoState();

                SetInitialized();
            }
            catch (Exception ex)
            {
                SetLoadFailed(ex.Message);
                Logger.LogError(ex.Message);
            }
        }
    private void InjectTransient()
    {
        _props = GetType().GetProperties()
                 .Where(property => property.GetCustomAttribute <InjectTransientAttribute>() != null)
                 .Where(property => {
            // We don't support set only, non public, or indexer properties
            if (property.GetMethod == null ||
                !property.GetMethod.IsPublic ||
                property.GetMethod.GetParameters().Length > 0)
            {
                return(false);
            }

            bool hasSetter = property.SetMethod is { IsPublic: true };

            if (!hasSetter)
            {
                return(false);
            }

            return(true);
        })
                 .ToList();

        foreach (PropertyInfo propertyInfo in _props)
        {
            object service = ScopedServices.GetRequiredService(propertyInfo.PropertyType);
            propertyInfo.SetValue(this, service);
        }
    }
Beispiel #13
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>();
                DataTableService   = ScopedServices.GetRequiredService <IDataTableService <Workstation, WorkstationFilter> >();
                SynchronizationService.UpdateWorkstationsPage += UpdateWorkstationsPage;

                switch (DashboardFilter)
                {
                case "NotApproved":
                    DataTableService.DataLoadingOptions.Filter.Approved = false;
                    break;

                case "Online":
                    //TODO
                    break;
                }

                await BreadcrumbsService.SetWorkstations();

                await DataTableService.InitializeAsync(WorkstationService.GetWorkstationsAsync, WorkstationService.GetWorkstationsCountAsync, StateHasChanged, nameof(Workstation.Name));

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Beispiel #14
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();
                TemplateService = ScopedServices.GetRequiredService <ITemplateService>();
                LdapService     = ScopedServices.GetRequiredService <ILdapService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                Templates = await TemplateService.GetTemplatesAsync();

                PersonalAccount = new AccountAddModel()
                {
                    EmployeeId = EmployeeId
                };

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #15
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }

                VaultProfiles          = new SelectList(await HardwareVaultService.GetProfilesAsync(), nameof(HardwareVaultProfile.Id), nameof(HardwareVaultProfile.Name));
                SelectedVaultProfileId = VaultProfiles.First().Value;

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #16
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService                = ScopedServices.GetRequiredService <IEmployeeService>();
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new HESException(HESCode.HardwareVaultNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #17
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();

                var email = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User.Identity.Name;
                User = await ApplicationUserService.GetUserByEmailAsync(email);

                UserProfileModel = new UserProfileModel
                {
                    UserId      = User.Id,
                    FullName    = User.FullName,
                    PhoneNumber = User.PhoneNumber
                };

                ChangeEmailModel = new ChangeEmailModel
                {
                    CurrentEmail = User.Email
                };

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Beispiel #18
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LicenseService = ScopedServices.GetRequiredService <ILicenseService>();

                LicenseOrder = await LicenseService.GetLicenseOrderByIdAsync(LicenseOrderId);

                if (LicenseOrder == null)
                {
                    throw new Exception("License Order not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(LicenseOrder.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(LicenseOrder.Id, LicenseOrder);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #19
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #20
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();
                LdapService     = ScopedServices.GetRequiredService <ILdapService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Account = await EmployeeService.GetAccountByIdAsync(AccountId);

                if (Account == null)
                {
                    throw new HESException(HESCode.AccountNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Account.Id, Account);
                }

                Employee = await EmployeeService.GetEmployeeByIdAsync(Account.EmployeeId);

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Beispiel #21
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                SharedAccountService           = ScopedServices.GetRequiredService <ISharedAccountService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                ModalDialogService.OnCancel += OnCancelAsync;

                Account = await SharedAccountService.GetSharedAccountByIdAsync(AccountId);

                if (Account == null)
                {
                    throw new Exception("Account not found");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Account.Id, Account);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Beispiel #22
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();
                FidoService            = ScopedServices.GetRequiredService <IFido2Service>();

                CurrentUser = await ApplicationUserService.GetUserByEmailAsync(await GetCurrentUserEmailAsync());

                // Password
                ChangePasswordModel = new ChangePasswordModel()
                {
                    UserId = CurrentUser.Id
                };

                // Security Key
                await LoadStoredCredentialsAsync();

                // 2FA
                await GetTwoFactorInfoAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Beispiel #23
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                GroupService = ScopedServices.GetRequiredService <IGroupService>();

                Group = await GroupService.GetGroupByIdAsync(GroupId);

                if (Group == null)
                {
                    throw new Exception("Group not found");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Group.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Group.Id, Group);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _gamesGroupService = (GamesGroupService)ScopedServices.GetRequiredService(typeof(GamesGroupService));

            Items = await _gamesGroupService.GetAllActive().ToListAsync();
        }
 protected override void OnInitialized()
 {
     AppSettingsService = ScopedServices.GetRequiredService <IAppSettingsService>();
     LdapSettings       = new LdapSettings()
     {
         Host = Host
     };
 }
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _contactTypeService = (ContactTypeService)ScopedServices.GetRequiredService(typeof(ContactTypeService));

            Items = await _contactTypeService.GetAllActive().ToListAsync();
        }
Beispiel #27
0
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _addressService = (AddressService)ScopedServices.GetRequiredService(typeof(AddressService));

            Items = await _addressService.GetAllActiveAddressesByUser(UserId).ToListAsync();
        }
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _cmsPageService = (CMSPageService)ScopedServices.GetRequiredService(typeof(CMSPageService));
            _appUserService = (AppUserService)ScopedServices.GetRequiredService(typeof(AppUserService));

            Items = await _cmsPageService.GetAllActive().ToListAsync();

            Users = await _appUserService.GetAllActive().ToListAsync();
        }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LicenseService       = ScopedServices.GetRequiredService <ILicenseService>();
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                LicenseOrder = await LicenseService.GetLicenseOrderByIdAsync(LicenseOrderId);

                if (LicenseOrder == null)
                {
                    throw new Exception("License Order not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(LicenseOrder.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(LicenseOrder.Id, LicenseOrder);
                }

                if (!LicenseOrder.ProlongExistingLicenses)
                {
                    _newLicenseOrder = new NewLicenseOrder()
                    {
                        ContactEmail   = LicenseOrder.ContactEmail,
                        Note           = LicenseOrder.Note,
                        StartDate      = LicenseOrder.StartDate.Value,
                        EndDate        = LicenseOrder.EndDate,
                        HardwareVaults = await HardwareVaultService.GetVaultsWithoutLicenseAsync()
                    };
                    _newLicenseOrder.HardwareVaults.ForEach(x => x.Checked = LicenseOrder.HardwareVaultLicenses.Any(d => d.HardwareVaultId == x.Id));
                }
                else
                {
                    _renewLicenseOrder = new RenewLicenseOrder()
                    {
                        ContactEmail   = LicenseOrder.ContactEmail,
                        Note           = LicenseOrder.Note,
                        EndDate        = LicenseOrder.EndDate,
                        HardwareVaults = await HardwareVaultService.GetVaultsWithLicenseAsync()
                    };
                    _renewLicenseOrder.HardwareVaults.ForEach(x => x.Checked = LicenseOrder.HardwareVaultLicenses.Any(d => d.HardwareVaultId == x.Id));
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();

                var userId = NavigationManager.GetQueryValue("userId");
                var code   = NavigationManager.GetQueryValue("code");
                var email  = NavigationManager.GetQueryValue("email");

                if (userId == null || email == null || code == null)
                {
                    SetWrongParameters("Wrong code", "This code is not valid.");
                    SetInitialized();
                    return;
                }

                var user = await UserManager.FindByIdAsync(userId);

                if (user == null)
                {
                    SetWrongParameters("User not found", "Unable to load user.");
                    SetInitialized();
                    return;
                }

                code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
                try
                {
                    await ApplicationUserService.ConfirmEmailChangeAsync(new UserConfirmEmailChangeModel()
                    {
                        UserId = userId, Email = email, Code = code
                    });

                    await IdentityApiClient.LogoutAsync();
                }
                catch (Exception ex)
                {
                    SetWrongParameters("Error changing email", ex.Message);
                    SetInitialized();
                    return;
                }

                Success = true;
                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }