Esempio n. 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"));
                }

                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)));
                }
            }
            else
            {
                DefaultPrompt = DataService.GetDefaultPrompt();
            }

            return(Page());
        }
Esempio n. 2
0
        private async Task PopulateViewModel()
        {
            CurrentUser = await _userManager.FindByEmailAsync(User.Identity.Name);

            Organization          = _dataService.GetOrganizationById(CurrentUser.OrganizationID);
            OrganizationName      = Organization.OrganizationName;
            IsDefaultOrganization = Organization.IsDefaultOrganization;
            var deviceGroups = _dataService.GetDeviceGroups(User.Identity.Name).OrderBy(x => x.Name);

            DeviceGroups.AddRange(deviceGroups);
            DeviceGroupSelectItems.AddRange(DeviceGroups.Select(x => new SelectListItem(x.Name, x.ID)));

            Users = _dataService.GetAllUsers(User.Identity.Name)
                    .Select(x => new OrganizationUser()
            {
                ID       = x.Id,
                IsAdmin  = x.IsAdministrator,
                UserName = x.UserName
            }).ToList();

            Invites = _dataService.GetAllInviteLinks(User.Identity.Name).Select(x => new Invite()
            {
                ID          = x.ID,
                InvitedUser = x.InvitedUser,
                IsAdmin     = x.IsAdmin,
                DateSent    = x.DateSent
            }).ToList();
        }
Esempio n. 3
0
        public void OnGet()
        {
            OrganizationName = DataService.GetOrganizationName(User.Identity.Name);

            var groups = DataService.GetDeviceGroupsForUserName(User.Identity.Name);

            DeviceGroups.AddRange(groups.Select(x => new SelectListItem(x.Name, x.ID)));

            Users = DataService.GetAllUsers(User.Identity.Name)
                    .Select(x => new OrganizationUser()
            {
                ID       = x.Id,
                IsAdmin  = x.IsAdministrator,
                UserName = x.UserName
            }).ToList();

            Invites = DataService.GetAllInviteLinks(User.Identity.Name).Select(x => new Invite()
            {
                ID          = x.ID,
                InvitedUser = x.InvitedUser,
                IsAdmin     = x.IsAdmin,
                DateSent    = x.DateSent,
                ResetUrl    = x.ResetUrl
            }).ToList();
        }
Esempio n. 4
0
        private void PopulateViewModel(string deviceID)
        {
            var user = DataService.GetUserByName(User.Identity.Name);

            if (user != null)
            {
                var device = DataService.GetDeviceForUser(user.Id, deviceID);
                DeviceName          = device?.DeviceName;
                AgentVersion        = device.AgentVersion;
                Input.Alias         = device?.Alias;
                Input.DeviceGroupID = device?.DeviceGroupID;
                Input.Tags          = device?.Tags;
            }
            var groups = DataService.GetDeviceGroupsForUserName(User.Identity.Name);

            DeviceGroups.AddRange(groups.Select(x => new SelectListItem(x.Name, x.ID)));
        }
Esempio n. 5
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());
        }
Esempio n. 6
0
        private void PopulateViewModel(string deviceID)
        {
            var user = DataService.GetUserByName(User.Identity.Name);

            if (user != null)
            {
                var device = DataService.GetDevice(user.OrganizationID, deviceID);
                DeviceName          = device?.DeviceName;
                DeviceID            = device?.ID;
                AgentVersion        = device?.AgentVersion;
                Input.Alias         = device?.Alias;
                Input.DeviceGroupID = device?.DeviceGroupID;
                Input.Tags          = device?.Tags;
                Input.Notes         = device?.Notes;
                Input.WebRtcSetting = device?.WebRtcSetting ?? default;
            }
            var groups = DataService.GetDeviceGroups(User.Identity.Name);

            DeviceGroups.AddRange(groups.Select(x => new SelectListItem(x.Name, x.ID)));
        }
Esempio n. 7
0
        private void PopulateViewModel()
        {
            OrganizationName = DataService.GetOrganizationName(User.Identity.Name);
            var deviceGroups = DataService.GetDeviceGroups(User.Identity.Name).OrderBy(x => x.Name);

            DeviceGroups.AddRange(deviceGroups);
            DeviceGroupSelectItems.AddRange(DeviceGroups.Select(x => new SelectListItem(x.Name, x.ID)));

            Users = DataService.GetAllUsers(User.Identity.Name)
                    .Select(x => new OrganizationUser()
            {
                ID       = x.Id,
                IsAdmin  = x.IsAdministrator,
                UserName = x.UserName
            }).ToList();

            Invites = DataService.GetAllInviteLinks(User.Identity.Name).Select(x => new Invite()
            {
                ID          = x.ID,
                InvitedUser = x.InvitedUser,
                IsAdmin     = x.IsAdmin,
                DateSent    = x.DateSent
            }).ToList();
        }