Ejemplo n.º 1
0
        public async Task<ActionResult> SecuritySettings(SecuritySettingsViewModel model)
        {
            var selectedSite = await siteManager.GetSiteForEdit(model.SiteId);
            // only server admin site can edit other sites settings
            if (selectedSite.Id == siteManager.CurrentSite.Id)
            {
                ViewData["Title"] = "Security Settings";
            }
            else if (siteManager.CurrentSite.IsServerAdminSite)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Security Settings", selectedSite.SiteName);
            }

            if (selectedSite == null)
            {
                this.AlertDanger(sr["oops something went wrong."], true);
                return RedirectToAction("Index");
            }

            if (model.SiteId == Guid.Empty)
            {
                this.AlertDanger(sr["oops something went wrong, site was not found."], true);
                return RedirectToAction("Index");
            }

            if (!ModelState.IsValid)
            {
                model.SmtpIsConfigured = selectedSite.SmtpIsConfigured();
                model.SmsIsConfigured = selectedSite.SmsIsConfigured();
                model.HasAnySocialAuthEnabled = selectedSite.HasAnySocialAuthEnabled();
                return View(model);
            }
            
            selectedSite.AccountApprovalEmailCsv = model.AccountApprovalEmailCsv;
            selectedSite.AllowNewRegistration = model.AllowNewRegistration;
            selectedSite.AllowPersistentLogin = model.AllowPersistentLogin;
            selectedSite.DisableDbAuth = model.DisableDbAuth;
            selectedSite.ReallyDeleteUsers = model.ReallyDeleteUsers;
            selectedSite.RequireApprovalBeforeLogin = model.RequireApprovalBeforeLogin;
            selectedSite.RequireConfirmedEmail = model.RequireConfirmedEmail;
            selectedSite.RequireConfirmedPhone = model.RequireConfirmedPhone;
            selectedSite.UseEmailForLogin = model.UseEmailForLogin;
            
            await siteManager.Update(selectedSite);
            
            this.AlertSuccess(string.Format(sr["Security Settings for {0} wwas successfully updated."],
                        selectedSite.SiteName), true);
            
            if ((siteManager.CurrentSite.IsServerAdminSite)
                && (siteManager.CurrentSite.Id != selectedSite.Id)
                )
            {
                return RedirectToAction("SecuritySettings", new { siteId = model.SiteId });
            }

            return RedirectToAction("SecuritySettings");
        }
Ejemplo n.º 2
0
        public async Task<ActionResult> SecuritySettings(SecuritySettingsViewModel model)
        {
            ISiteSettings selectedSite = null;
            if (model.SiteGuid == siteManager.CurrentSite.SiteGuid)
            {
                selectedSite = siteManager.CurrentSite;
                ViewData["Title"] = "Security Settings";
            }
            else if (siteManager.CurrentSite.IsServerAdminSite)
            {
                selectedSite = await siteManager.Fetch(model.SiteGuid);
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Security Settings", selectedSite.SiteName);
            }

            if (selectedSite == null)
            {
                this.AlertDanger("oops something went wrong.", true);

                return RedirectToAction("Index");
            }

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            if (model.SiteGuid == Guid.Empty)
            {
                this.AlertDanger("oops something went wrong, site was not found.", true);

                return RedirectToAction("Index");
            }
            
            selectedSite.AllowNewRegistration = model.AllowNewRegistration;
            selectedSite.AllowPersistentLogin = model.AllowPersistentLogin;
            selectedSite.DisableDbAuth = model.DisableDbAuth;
            selectedSite.ReallyDeleteUsers = model.ReallyDeleteUsers;
            selectedSite.RequireApprovalBeforeLogin = model.RequireApprovalBeforeLogin;
            selectedSite.UseSecureRegistration = model.RequireEmailConfirmation;
            selectedSite.UseEmailForLogin = model.UseEmailForLogin;

            bool result = await siteManager.Save(selectedSite);

            if (result)
            {
                this.AlertSuccess(string.Format("Security Settings for <b>{0}</b> wwas successfully updated.",
                            selectedSite.SiteName), true);
            }


            if ((siteManager.CurrentSite.IsServerAdminSite)
                && (siteManager.CurrentSite.SiteGuid != selectedSite.SiteGuid)
                )
            {

                return RedirectToAction("SecuritySettings", new { siteGuid = model.SiteGuid });
            }

            return RedirectToAction("SecuritySettings");

        }
Ejemplo n.º 3
0
        public async Task<IActionResult> SecuritySettings(
            Guid? siteId,
            int slp = 1)
        {
            var selectedSite = await siteManager.GetSiteForEdit(siteId);
            // only server admin site can edit other sites settings
            if (selectedSite.Id != siteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Security Settings"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = sr["Security Settings"];
            }

            var model = new SecuritySettingsViewModel();
            model.SiteId = selectedSite.Id;
            model.AllowNewRegistration = selectedSite.AllowNewRegistration;
            model.AllowPersistentLogin = selectedSite.AllowPersistentLogin;
            model.DisableDbAuth = selectedSite.DisableDbAuth;
            model.ReallyDeleteUsers = selectedSite.ReallyDeleteUsers;
            model.RequireApprovalBeforeLogin = selectedSite.RequireApprovalBeforeLogin;
            model.RequireConfirmedEmail = selectedSite.RequireConfirmedEmail;
            model.UseEmailForLogin = selectedSite.UseEmailForLogin;
            model.RequireConfirmedPhone = selectedSite.RequireConfirmedPhone;
            model.AccountApprovalEmailCsv = selectedSite.AccountApprovalEmailCsv;

            model.SmtpIsConfigured = selectedSite.SmtpIsConfigured();
            model.SmsIsConfigured = selectedSite.SmsIsConfigured();
            model.HasAnySocialAuthEnabled = selectedSite.HasAnySocialAuthEnabled();

            return View(model);
        }
Ejemplo n.º 4
0
        public async Task<IActionResult> SecuritySettings(
            Guid? siteGuid,
            int slp = 1)
        {

            ISiteSettings selectedSite;
            // only server admin site can edit other sites settings
            if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite))
            {
                selectedSite = await siteManager.Fetch(siteGuid.Value);
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Security Settings", selectedSite.SiteName);
            }
            else
            {
                selectedSite = siteManager.CurrentSite;
                ViewData["Title"] = "Security Settings";
            }

            SecuritySettingsViewModel model = new SecuritySettingsViewModel();
            model.SiteGuid = selectedSite.SiteGuid;
            model.SiteId = selectedSite.SiteId;
            model.AllowNewRegistration = selectedSite.AllowNewRegistration;
            model.AllowPersistentLogin = selectedSite.AllowPersistentLogin;
            model.DisableDbAuth = selectedSite.DisableDbAuth;
            model.ReallyDeleteUsers = selectedSite.ReallyDeleteUsers;
            model.RequireApprovalBeforeLogin = selectedSite.RequireApprovalBeforeLogin;
            model.RequireEmailConfirmation = selectedSite.UseSecureRegistration;
            model.UseEmailForLogin = selectedSite.UseEmailForLogin;

            return View(model);


        }