Beispiel #1
0
        public async Task <IActionResult> OnGet()
        {
            if (User?.Identity?.IsAuthenticated == true)
            {
                var user = _dataService.GetUserByName(User.Identity.Name);
                if (user is null)
                {
                    await _signInManager.SignOutAsync();

                    return(RedirectToPage());
                }

                if (_appConfig.Require2FA && !user.TwoFactorEnabled)
                {
                    return(RedirectToPage("TwoFactorRequired"));
                }

                var organizationCount = _dataService.GetOrganizationCount();
                RegistrationAvailable = _appConfig.MaxOrganizationCount < 0 || organizationCount < _appConfig.MaxOrganizationCount;

                var org = _dataService.GetOrganizationById(user.OrganizationID);
                IsNewVersionAvailable = await _upgradeService.IsNewVersionAvailable();

                DefaultPrompt = _dataService.GetDefaultPrompt(User.Identity.Name);
                var groups = _dataService.GetDeviceGroups(User.Identity.Name);
                if (groups?.Any() == true)
                {
                    DeviceGroups.AddRange(groups.Select(x => new SelectListItem(x.Name, x.ID)));
                }
                var alerts = _dataService.GetAlerts(user.Id);
                if (alerts.Any())
                {
                    Alerts.AddRange(alerts);
                }

                Motd = _appConfig.MessageOfTheDay;
            }
            else
            {
                DefaultPrompt = _dataService.GetDefaultPrompt();
            }

            return(Page());
        }