Exemple #1
0
        public MetaResponse Login(ApiCall call)
        {
            // get the redirect url.
            MetaResponse res = new MetaResponse();

            res.Redirect("/_admin/sites");
            return(res);
        }
Exemple #2
0
        public MetaResponse Inline(ApiCall call)
        {
            if (call.Context.User == null)
            {
                throw new Exception("Require user login first");
            }

            var sitedb   = call.Context.WebSite.SiteDb();
            var siteid   = call.GetValue <Guid>("SiteId");
            var pageid   = call.GetValue <Guid>("PageId");
            var isMobile = call.GetValue <bool>("isMobile");//for test using browser
            var route    = sitedb.Routes.GetByObjectId(pageid);

            sitedb.Routes.GetObjectPrimaryRelativeUrl(pageid);

            string baseurl = sitedb.WebSite.BaseUrl();

            var pageurl = sitedb.Routes.GetObjectPrimaryRelativeUrl(pageid);

            string fullpageurl = Kooboo.Lib.Helper.UrlHelper.Combine(baseurl, pageurl);

            var newtoken = Kooboo.Data.Cache.AccessTokenCache.GetNewToken(call.Context.User.Id);

            string url = null;

            if (IsMobile(call) || isMobile)
            {
                url = "/_Admin/Phone/Index";
            }
            else
            {
                url = "/_Admin/Sites/Edit";
            }

            url += "?SiteId=" + siteid.ToString() + "&pageId=" + pageid.ToString();

            url += "&accessToken=" + newtoken;

            url += "&pageUrl=" + System.Net.WebUtility.UrlEncode(fullpageurl);

            url = Lib.Helper.UrlHelper.Combine(baseurl, url);
            /// /_Admin/Sites/Edit?SiteId=55b15904-3725-6cd8-9dfe-c58c52e7861f&pageId=5b4335d3-becc-4831-97d0-57adbc065cfd&pageUrl=http%3A%2F%2Fsss.kooboo%3A82%2Fsdfsdfsd&accessToken=ycc0xnXIkEinKo_G851TwQ
            //var url = "/"
            MetaResponse res = new MetaResponse();

            res.Redirect(url);
            return(res);
        }
Exemple #3
0
        public IResponse Form(ApiCall call)
        {
            // in the format of /_api/submit/form/xxxyyssss;
            var  sitedb = call.WebSite.SiteDb();
            Guid FormId = Lib.Security.ShortGuid.Decode(call.Command.Value);

            var formsetting = sitedb.FormSetting.GetByFormId(FormId);

            if (formsetting != null && !string.IsNullOrEmpty(formsetting.FormSubmitter))
            {
                var submitter = Sites.HtmlForm.FormManager.GetSubmitter(formsetting.FormSubmitter);
                submitter.Submit(call.Context, formsetting.FormId, formsetting.Setting);

                if (call.Context.Response.End || call.Context.Response.StatusCode >= 300)
                {
                    return(new NoResponse());
                }

                MetaResponse response = new MetaResponse();
                response.Success = true;

                if (!formsetting.AllowAjax && !string.IsNullOrEmpty(formsetting.RedirectUrl))
                {
                    string url = formsetting.RedirectUrl;
                    if (!url.ToLower().StartsWith("http://") && !url.ToLower().StartsWith("https://"))
                    {
                        if (url.ToLower() == Kooboo.Sites.SiteConstants.SelfRefreshUrl)
                        {
                            string formurlvalue = call.GetValue(Sites.HtmlForm.FormManager.FormUrlName);
                            if (!string.IsNullOrEmpty(formurlvalue))
                            {
                                url = formurlvalue;
                                if (!url.ToLower().StartsWith("http://") && !url.ToLower().StartsWith("https://"))
                                {
                                    string baseurl = call.Context.WebSite.BaseUrl();
                                    url = Lib.Helper.UrlHelper.Combine(baseurl, url);
                                }
                            }
                            else
                            {
                                var form = sitedb.Forms.Get(FormId);
                                url = Kooboo.Sites.Service.ObjectService.GetObjectFullUrl(call.Context.WebSite, form.OwnerObjectId);
                            }
                        }
                        else
                        {
                            string baseurl = call.Context.WebSite.BaseUrl();
                            url = Kooboo.Lib.Helper.UrlHelper.Combine(baseurl, url);
                        }
                        response.Redirect(url);
                        return(response);
                    }
                    else
                    {
                        response.Redirect(url);
                        return(response);
                    }
                }

                return(response);
            }

            return(null);
        }