Esempio n. 1
0
 public FrontHtmlHelper(Page_Context context, HtmlHelper html, ViewRender viewRender, ProxyRender proxyRender)
 {
     this.PageContext = context;
     this.Html = html;
     this.ViewRender = viewRender;
     this.ProxyRender = proxyRender;
 }
Esempio n. 2
0
 public FrontHtmlHelper(Page_Context context, HtmlHelper html, ViewRender viewRender, ProxyRender proxyRender)
 {
     this.PageContext = context;
     this.Html        = html;
     this.ViewRender  = viewRender;
     this.ProxyRender = proxyRender;
 }
Esempio n. 3
0
 private ActionResult Authorizate(Page_Context context)
 {
     if (!MemberAuth.IsAuthenticated())
     {
         return new RedirectResult(context.Url.FrontUrl().PageUrl("SignIN", new { returnUrl = context.ControllerContext.HttpContext.Request.RawUrl }).ToString());
     }
     return null;
 }
        public System.Web.Mvc.ActionResult HttpGet(Page_Context context, PagePositionContext positionContext)
        {
            _responseManager.SetHeader("SamplePlugin", "GET");

            //context.ControllerContext.Controller.ViewBag.ovos = "ovos";

            //context.ControllerContext.Controller.ControllerContext.
            
            return null;
        }
Esempio n. 5
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            HttpRequestBase request = context.ControllerContext.HttpContext.Request;
            Controller controller = (Controller)context.ControllerContext.Controller;
            string username = request.Form["username"];
            string email = request.Form["email"];
            try
            {
                if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(email))
                {
                    controller.ViewData.ModelState.AddModelError("", "Username or Email is required.".Localize());
                    return null;
                }
                else if (controller.ViewData.ModelState.IsValid)
                {
                    var repository = Repository.Current;
                    var textFolder = new TextFolder(repository, "Members");
                    TextContent content = null;
                    if (!string.IsNullOrEmpty(username))
                    {
                        content = textFolder.CreateQuery().WhereEquals("UserName", username).FirstOrDefault();
                        email = content.Get<string>("Email");
                    }
                    else
                    {
                        content = textFolder.CreateQuery().WhereEquals("Email", email).FirstOrDefault();
                        username = content.Get<string>("UserName");
                    }
                    if (content != null)
                    {
                        string randomValue = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(16);
                        ServiceFactory.TextContentManager.Update(textFolder, content.UUID, new string[] { "ForgotPWToken" }, new object[] { randomValue });

                        string link = new Uri(request.Url, string.Format("ResetPassword?UserName={0}&token={1}".RawLabel().ToString(), username, randomValue)).ToString();
                        string emailBody = "<b>{0}</b> <br/><br/> To change your password, click on the following link:<br/> <br/> <a href='{1}'>{1}</a> <br/>".RawLabel().ToString();
                        string subject = "Reset your password".RawLabel().ToString();
                        string body = string.Format(emailBody, username, link);
                        SendMail(email, subject, body, false);
                    }
                    else
                    {
                        controller.ViewData.ModelState.AddModelError("", "The user does not exists.".RawLabel().ToString());
                    }
                    controller.ViewBag.Message = "An email with instructions to choose a new password has been sent to you.".RawLabel().ToString();
                }
            }
            catch (Exception e)
            {
                controller.ViewData.ModelState.AddModelError("", e.Message);
            }

            return null;
        }
Esempio n. 6
0
 public System.Web.Mvc.ActionResult HttpGet(Page_Context context, PagePositionContext positionContext)
 {
     HttpRequestBase request = context.ControllerContext.HttpContext.Request;
     Controller controller = (Controller)context.ControllerContext.Controller;
     string username = request.Params["UserName"];
     string token = request.Params["token"];
     if (!ValidateMemberPasswordToken(username, token))
     {
         context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "The password token is invalid.".Localize());
     }
     return null;
 }
Esempio n. 7
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            HttpRequestBase request = context.ControllerContext.HttpContext.Request;
            Controller controller = (Controller)context.ControllerContext.Controller;
            string username = request.Params["UserName"];
            string token = request.Params["token"];
            if (!ValidateMemberPasswordToken(username, token))
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "The password token is invalid.".Localize());
                return null;
            }
            AntiForgery.Validate();

            var newPassword = request.Form["newpassword"];
            var confirmPassword = request.Form["confirmPassword"];
            if (newPassword != confirmPassword)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "The passwords do not match.".RawLabel().ToString());
                return null;
            }
            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");
                var content = textFolder.CreateQuery().WhereEquals("UserName", username).FirstOrDefault();

                var passwordSalt = "";
                if (content["PasswordSalt"] == null)
                {
                    passwordSalt = MemberAuth.GenerateSalt();
                }
                else
                {
                    passwordSalt = content["PasswordSalt"].ToString();
                }

                newPassword = MemberAuth.EncryptPassword(newPassword, passwordSalt);

                ServiceFactory.TextContentManager.Update(textFolder, content.UUID,
                    new string[] { "Password", "ForgotPWToken", "PasswordSalt" }, new object[] { newPassword, "", passwordSalt });
                context.ControllerContext.Controller.ViewBag.Message = "The password has been changed.".Label();

                MemberAuth.SetAuthCookie(username, false);
                return new RedirectResult(context.Url.FrontUrl().PageUrl("Dashboard").ToString());
            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Esempio n. 8
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            AntiForgery.Validate();

            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");
                var userContent = MemberAuth.GetMemberContent();

                var oldPassword = httpContext.Request.Form["OldPassword"];
                var newPassword = httpContext.Request.Form["NewPassword"];

                if (userContent["PasswordSalt"] != null)
                {
                    oldPassword = MemberAuth.EncryptPassword(oldPassword, userContent["PasswordSalt"].ToString());
                }
                if (userContent["password"].ToString() == oldPassword)
                {
                    var passwordSalt = "";
                    if (userContent["PasswordSalt"] == null)
                    {
                        passwordSalt = MemberAuth.GenerateSalt();
                    }
                    else
                    {
                        passwordSalt = userContent["PasswordSalt"].ToString();
                    }

                    newPassword = MemberAuth.EncryptPassword(newPassword, passwordSalt);

                    ServiceFactory.TextContentManager.Update(textFolder, userContent.UUID, new string[] { "Password", "PasswordSalt" }, new object[] { newPassword, passwordSalt });
                    context.ControllerContext.Controller.ViewBag.Message = "The password has been changed.".RawLabel().ToString();
                }
                else
                {
                    context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "The old password is invalid.".RawLabel().ToString());
                }
            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Esempio n. 9
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            AntiForgery.Validate();

            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");

                string username = httpContext.Request.Form["username"];
                string password = httpContext.Request.Form["password"];

                var member = textFolder.CreateQuery().WhereEquals("UserName", username).FirstOrDefault();

                if (member != null)
                {
                    var encryptedPassword = password;
                    if (member["PasswordSalt"] != null)
                    {
                        var passwordSalt = member["PasswordSalt"].ToString();
                        encryptedPassword = MemberAuth.EncryptPassword(password, passwordSalt);
                    }
                    if (encryptedPassword == member["Password"].ToString())
                    {
                        var rememberme = httpContext.Request.Form["rememberMe"].Contains("true");
                        var returnUrl = httpContext.Request.QueryString["returnUrl"];
                        if (string.IsNullOrEmpty(returnUrl))
                        {
                            returnUrl = context.Url.FrontUrl().PageUrl("Dashboard").ToString();
                        }
                        MemberAuth.SetAuthCookie(username, rememberme);
                        return new RedirectResult(returnUrl);
                    }
                }
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "Username or password is invalid".RawLabel().ToString());
                return null;

            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Esempio n. 10
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            AntiForgery.Validate();

            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");
                var values = new NameValueCollection(httpContext.Request.Form);
                values["Published"] = true.ToString();

                var member = textFolder.CreateQuery().WhereEquals("UserName", values["username"]).FirstOrDefault();
                if (member != null)
                {
                    context.ControllerContext.Controller.ViewData.ModelState.AddModelError("UserName", "The user already exists.".RawLabel().ToString());
                }
                else
                {
                    values["PasswordSalt"] = MemberAuth.GenerateSalt();
                    values["Password"] = MemberAuth.EncryptPassword(values["Password"], values["PasswordSalt"]);

                    var textContext = ServiceFactory.TextContentManager.Add(repository, textFolder, null, null,
                       values, httpContext.Request.Files, null, httpContext.User.Identity.Name);

                    MemberAuth.SetAuthCookie(textContext["UserName"].ToString(), false);

                    return new RedirectResult(context.Url.FrontUrl().PageUrl("Dashboard").ToString());
                }

            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Esempio n. 11
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            AntiForgery.Validate();

            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");
                var userContent = MemberAuth.GetMemberContent();

                var email = httpContext.Request.Form["Email"];
                var language = httpContext.Request.Form["Language"];

                ServiceFactory.TextContentManager.Update(textFolder, userContent.UUID, new string[] { "Email", "Language" }, new object[] { email, language });
            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Esempio n. 12
0
 protected abstract void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder);
Esempio n. 13
0
 public PageSettingValueProvider(Page_Context pageContext)
 {
     this._pageContext = pageContext;
 }
Esempio n. 14
0
 protected abstract void BySchema(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, Schema schema);
 public PageSettingValueProvider(Page_Context pageContext)
 {
     this._pageContext = pageContext;
 }
Esempio n. 16
0
        protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;
            string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid");

            var addCategories = GetCategories("AddCategories", pageContext.ControllerContext);
            var removeCategories = GetCategories("RemoveCategories", pageContext.ControllerContext);
            try
            {
                Content.Services.ServiceFactory.TextContentManager.Update(repository, folder, uuid, httpContext.Request.Form
                    , httpContext.Request.Files, DateTime.UtcNow, addCategories, removeCategories, httpContext.User.Identity.Name);
            }
            catch (RuleViolationException violationException)
            {
                violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
            }
        }
Esempio n. 17
0
 protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder)
 {
     string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid");
     try
     {
         Content.Services.ServiceFactory.TextContentManager.Delete(repository, folder, uuid);
     }
     catch (RuleViolationException violationException)
     {
         violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
     }
 }
Esempio n. 18
0
 public FrontHtmlHelper(Page_Context context, HtmlHelper html)
 {
     this.PageContext = context;
     this.Html        = html;
 }
Esempio n. 19
0
 public System.Web.Mvc.ActionResult HttpGet(Page_Context context, PagePositionContext positionContext)
 {
     return null;
 }
Esempio n. 20
0
        /// <summary>
        /// <example>
        /// <div>
        //        <div>
        //    <form method="post">
        //    <input type="hidden" name="FolderName" value="news" />
        //    <input type="hidden" name="Published" value="true" />
        //    <input type="hidden" name="Categories[0].FolderName" value="<%: ViewBag.category.FolderName %>" />
        //    <input type="hidden" name="Categories[0].UUID" value="<%: ViewBag.category.UUID %>" />
        //    <table>
        //        <tr>
        //            <td>
        //                title:
        //            </td>
        //            <td>
        //                <input type="text" name="title" data-val-required="title is required" data-val="true" />
        //                <%: Html.ValidationMessageForInput("title") %>
        //            </td>
        //        </tr>
        //        <tr>
        //            <td>
        //                body:
        //            </td>
        //            <td>
        //                <textarea name="body" cols="20" rows="10"></textarea>
        //            </td>
        //        </tr>
        //    </table>
        //    <input type="submit" name="submit" value="submit" />
        //    </form>
        //</div>
        /// </example>
        /// </summary>
        /// <param name="pageContext"></param>
        /// <param name="repository"></param>
        /// <param name="folder"></param>
        protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;

            var categories = GetCategories("Categories", pageContext.ControllerContext);

            try
            {
                var parentFolder = httpContext.Request.Form["ParentFolder"];
                var parentUUID = httpContext.Request.Form["ParentUUID"];
                Content.Services.ServiceFactory.TextContentManager.Add(repository, folder, parentFolder, parentUUID,
                  httpContext.Request.Form, httpContext.Request.Files, categories, httpContext.User.Identity.Name);
            }
            catch (RuleViolationException violationException)
            {
                violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
            }
        }
Esempio n. 21
0
        protected override void BySchema(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, Schema schema)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;
            string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid");

            try
            {
                Content.Services.ServiceFactory.TextContentManager.Update(repository, schema, uuid, httpContext.Request.Form
                    , httpContext.Request.Files, httpContext.User.Identity.Name);
            }
            catch (RuleViolationException violationException)
            {
                violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
            }
        }
Esempio n. 22
0
 public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
 {
     _responseManager.SetHeader("SamplePlugin", "POST");
     return null;
 }
Esempio n. 23
0
 public System.Web.Mvc.ActionResult Execute(Page_Context pageViewContext, PagePositionContext positionContext)
 {
     //pageViewContext.ControllerContext.HttpContext.Response.Write("Sample plugin executed.<br/>");
     return null;
 }
Esempio n. 24
0
 public FrontHtmlHelper(Page_Context context, HtmlHelper html)
 {
     this.PageContext = context;
     this.Html = html;
 }
Esempio n. 25
0
        public ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            var httpContext = context.ControllerContext.RequestContext.HttpContext;

            var site = context.PageRequestContext.Site;

            var repository = site.GetRepository();
            if (repository == null)
            {
                throw new SiteRepositoryNotExists();
            }
            object model = null;
            Exception exception = null;
            try
            {
                var folderName = context.ControllerContext.RequestContext.GetRequestValue("FolderName");
                if (!string.IsNullOrEmpty(folderName))
                {
                    var folder = FolderHelper.Parse<TextFolder>(repository, folderName);
                    model = DoPost(repository, folder, context.ControllerContext, context.ControllerContext.HttpContext.Request.Form);
                }
            }
            catch (Exception e)
            {
                exception = e;
            }

            return PluginHelper.ReturnActionResult(context.ControllerContext, model, exception);
        }
Esempio n. 26
0
 public ActionResult HttpGet(Page_Context context, PagePositionContext positionContext)
 {
     return null;
 }