Exemple #1
0
        /// <summary>
        /// Assure that there is at least one system user beloning to the admin group
        /// </summary>
        internal static void AssureAdminSystemUser()
        {
            SystemUserGroup group =
                Db.SQL <SystemUserGroup>("SELECT o FROM Simplified.Ring3.SystemUserGroup o WHERE o.Name = ?",
                                         AdminGroupName).First;
            SystemUser user =
                Db.SQL <SystemUser>("SELECT o FROM Simplified.Ring3.SystemUser o WHERE o.Username = ?", AdminUsername)
                .First;

            if (group != null && user != null && SystemUser.IsMemberOfGroup(user, group))
            {
                return;
            }

            // There is no system user beloning to the admin group
            Db.Transact(() =>
            {
                if (group == null)
                {
                    group             = new SystemUserGroup();
                    group.Name        = AdminGroupName;
                    group.Description = AdminGroupDescription;
                }

                if (user == null)
                {
                    Person person = new Person()
                    {
                        FirstName = AdminUsername,
                        LastName  = AdminUsername
                    };

                    user        = SystemUser.RegisterSystemUser(AdminUsername, AdminEmail, AdminPassword);
                    user.WhatIs = person;
                }

                // Add the admin group to the system admin user
                SystemUserGroupMember member = new Simplified.Ring3.SystemUserGroupMember();

                member.WhatIs = user;
                member.ToWhat = group;
            });
        }
        public void RefreshCurrentPage()
        {
            if (string.IsNullOrEmpty(this.PartialUrl))
            {
                this.CurrentPage = null;
                return;
            }

            SystemUser user = SystemUser.GetCurrentSystemUser();

            if (SystemUser.IsMemberOfGroup(user, allowedSystemUserGroup))
            {
                this.CurrentPage = Self.GET(this.PartialUrl);
            }
            else
            {
                this.CurrentPage = Self.GET("/website/partials/deny");
            }
        }
Exemple #3
0
 private static bool IsInGroup(SystemUser user, SystemUserGroup group)
 {
     return(group != null && user != null && SystemUser.IsMemberOfGroup(user, group));
 }