예제 #1
0
        private void CreateGod()
        {
            UserAccount god = m_UserAccountService.GetUserAccount(UUID.Zero, m_WebApp.AdminFirst, m_WebApp.AdminLast);

            if (god == null)
            {
                m_log.DebugFormat("[Wifi]: Administrator account {0} {1} does not exist. Creating it...", m_WebApp.AdminFirst, m_WebApp.AdminLast);
                // Doesn't exist. Create one
                god           = new UserAccount(UUID.Zero, m_WebApp.AdminFirst, m_WebApp.AdminLast, m_WebApp.AdminEmail);
                god.UserLevel = m_WebApp.AdminUserLevel;
                god.UserTitle = "Administrator";
                god.UserFlags = 0;
                SetServiceURLs(god);
                m_UserAccountService.StoreUserAccount(god);
                m_InventoryService.CreateUserInventory(god.PrincipalID);
                if (m_WebApp.AdminPassword == string.Empty)
                {
                    // Signal that the App needs installation
                    m_WebApp.IsInstalled = false;
                }
                else
                {
                    m_AuthenticationService.SetPassword(god.PrincipalID, m_WebApp.AdminPassword);
                    m_WebApp.IsInstalled = true;
                }
            }
            else
            {
                m_log.DebugFormat("[Wifi]: Administrator account {0} {1} exists.", m_WebApp.AdminFirst, m_WebApp.AdminLast);
                // Signal that the App has been previously installed
                m_WebApp.IsInstalled = true;
            }

            if (god.UserLevel < m_WebApp.AdminUserLevel)
            {
                // Might have existed but had wrong UserLevel
                god.UserLevel = m_WebApp.AdminUserLevel;
                m_UserAccountService.StoreUserAccount(god);
            }
        }