예제 #1
0
 public ActionResult OnPostDelete()
 {
     StreamingLiveLib.Role r = StreamingLiveLib.Role.Load(Id, AppUser.Current.Site.Id);
     StreamingLiveLib.Role.Delete(r.Id);
     if (StreamingLiveLib.Roles.LoadByUserId(Id).Count == 0)
     {
         StreamingLiveLib.User.Delete(Id);
     }
     return(Redirect("/cp/users/"));
 }
예제 #2
0
        private void ShowEditUser(int userId)
        {
            StreamingLiveLib.User selectedUser = (userId == 0) ? new StreamingLiveLib.User() : StreamingLiveLib.User.Load(userId);
            StreamingLiveLib.Role selectedRole = StreamingLiveLib.Role.Load(userId, AppUser.Current.Site.Id);

            Id          = selectedUser.Id;
            Email       = selectedUser.Email;
            DisplayName = selectedUser.DisplayName;
            Password    = selectedUser.Password;

            SelectedRole = (selectedRole == null) ? "" : selectedRole.Name;
            ShowEdit     = true;
        }
예제 #3
0
        public void OnPostSave()
        {
            string[] errors = Validate(Id);
            if (errors.Length == 0)
            {
                if (Id == 0)
                {
                    StreamingLiveLib.User existing = StreamingLiveLib.User.LoadByEmail(Email);
                    if (existing == null)
                    {
                        StreamingLiveLib.User user = new StreamingLiveLib.User();
                        user.DisplayName = DisplayName;
                        user.Email       = Email;
                        user.Password    = StreamingLiveLib.User.HashPassword(Password);
                        user.Save();
                        Id = user.Id;
                    }
                    else
                    {
                        Id = existing.Id;
                    }
                    new StreamingLiveLib.Role()
                    {
                        SiteId = AppUser.Current.Site.Id, Name = SelectedRole, UserId = Id
                    }.Save();
                }
                else
                {
                    StreamingLiveLib.Role role = StreamingLiveLib.Role.Load(Id, AppUser.Current.Site.Id);
                    role.Name = SelectedRole;
                    role.Save();
                }

                Populate();
                OutputMessage = Utils.FormatMessage("<b>Success:</b> Changes saved.", false);
            }
            else
            {
                OutputMessage = Utils.FormatMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true);
            }
        }
예제 #4
0
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            string[] errors = Validate();
            if (errors.Length == 0)
            {
                StreamingLiveLib.Site s = new StreamingLiveLib.Site()
                {
                    KeyName = KeyNameText.Text.ToLower().Trim(), PrimaryColor = "#24b9ff", ContrastColor = "#ffffff", HeaderColor = "#24b9ff", HomePageUrl = "/", LogoUrl = "/data/master/logo.png", RegistrationDate = DateTime.UtcNow
                };
                s.Save();

                StreamingLiveLib.User u = new StreamingLiveLib.User()
                {
                    Email = EmailText.Text.ToLower().Trim(), Password = StreamingLiveLib.User.HashPassword(PasswordText.Text.Trim()), DisplayName = "Admin"
                };
                u.ResetGuid = Guid.NewGuid().ToString();
                u.Save();

                StreamingLiveLib.Role r = new StreamingLiveLib.Role()
                {
                    Name = "admin", SiteId = s.Id, UserId = u.Id
                };
                r.Save();


                new StreamingLiveLib.Button()
                {
                    SiteId = s.Id, Sort = 1, Text = "Resources", Url = "about:blank"
                }.Save();
                new StreamingLiveLib.Button()
                {
                    SiteId = s.Id, Sort = 2, Text = "Give", Url = "about:blank"
                }.Save();

                new StreamingLiveLib.Tab()
                {
                    SiteId = s.Id, Sort = 1, TabType = "chat", TabData = "", Icon = "far fa-comment", Text = "Chat", Url = ""
                }.Save();
                new StreamingLiveLib.Tab()
                {
                    SiteId = s.Id, Sort = 2, TabType = "url", TabData = "", Icon = "fas fa-bible", Text = "Bible", Url = "https://www.bible.com/en-GB/bible/111/GEN.1.NIV"
                }.Save();
                new StreamingLiveLib.Tab()
                {
                    SiteId = s.Id, Sort = 3, TabType = "prayer", TabData = "", Icon = "fas fa-praying-hands", Text = "Prayer", Url = ""
                }.Save();

                DateTime serviceTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9 + 5, 0, 0).AddDays(1);
                while (serviceTime.DayOfWeek != DayOfWeek.Sunday)
                {
                    serviceTime = serviceTime.AddDays(1);
                }
                new StreamingLiveLib.Service()
                {
                    SiteId = s.Id, ChatAfter = 15 * 60, ChatBefore = 15 * 60, Duration = 60 * 60, EarlyStart = 5 * 60, Provider = "youtube_watchparty", ProviderKey = "zFOfmAHFKNw", VideoUrl = "https://www.youtube.com/embed/zFOfmAHFKNw?autoplay=1&controls=0&showinfo=0&rel=0&modestbranding=1&disablekb=1", ServiceTime = serviceTime, TimezoneOffset = 300, Recurring = false
                }.Save();

                System.IO.Directory.CreateDirectory(Server.MapPath("/data/" + s.KeyName));
                System.IO.File.Copy(Server.MapPath("/data/master/data.json"), Server.MapPath("/data/" + s.KeyName + "/data.json"));
                System.IO.File.Copy(Server.MapPath("/data/master/data.css"), Server.MapPath("/data/" + s.KeyName + "/data.css"));

                try
                {
                    string body = "<a href=\"https://" + s.KeyName + ".streaminglive.church/\">https://" + s.KeyName + ".streaminglive.church/</a> - " + u.Email;
                    StreamingLiveLib.Aws.EmailHelper.SendEmail(CachedData.SupportEmail, CachedData.SupportEmail, "New StreamingLive.church Registration", body);
                } catch { }



                AppUser.Login(u);
                FormsAuthentication.SetAuthCookie(u.ResetGuid.ToString(), true);
                Response.Redirect("/cp/welcome.aspx");
            }
            else
            {
                OutputMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true, OutputLit);
            }
        }