Example #1
0
        public ThemeEntity GetCurrentTheme()
        {
            var         id    = _cookie.GetValue <string>(PreViewCookieName);
            ThemeEntity theme = null;

            if (id.IsNotNullAndWhiteSpace() && (_httpContextAccessor.HttpContext.User?.Identity.IsAuthenticated ?? false))
            {
                theme = Get(id);
                if (theme != null)
                {
                    theme.IsPreView   = true;
                    theme.UrlDebugger = VersionSource(theme.UrlDebugger);
                    theme.Url         = VersionSource(theme.Url);
                }
            }
            if (theme == null)
            {
                theme = _cache.GetOrAdd(CurrentThemeCacheKey, key =>
                {
                    ThemeEntity entry = Get(m => m.IsActived == true).FirstOrDefault();
                    entry.UrlDebugger = VersionSource(entry.UrlDebugger);
                    entry.Url         = VersionSource(entry.Url);
                    return(entry);
                }) as ThemeEntity;
            }
            return(theme);
        }
Example #2
0
        public ActionResult Design(string ID)
        {
            // Stop Caching in IE


            // Stop Caching in Firefox

            ViewBag.CanPasteWidget = _cookie.GetValue <string>(Const.CopyWidgetCookie).IsNotNullAndWhiteSpace();
            return(View());
        }
        public ActionResult SelectWidget(QueryContext context)
        {
            var viewModel = new WidgetTemplateViewModel
            {
                PageID          = context.PageID,
                LayoutID        = context.LayoutID,
                ZoneID          = context.ZoneID,
                ReturnUrl       = context.ReturnUrl,
                CanPasteWidget  = context.ZoneID.IsNotNullAndWhiteSpace() && _cookie.GetValue <string>(Const.CopyWidgetCookie).IsNotNullAndWhiteSpace(),
                WidgetTemplates = Service.GetAll().OrderBy(m => m.Order).ToList()
            };

            return(View(viewModel));
        }
        public ActionResult LogOn()
        {
            IAuthenticationResponse response = openId.Response;

            if (response != null)
            {
                if ((response.Status == AuthenticationStatus.Failed) || (response.Status == AuthenticationStatus.Canceled))
                {
                    ModelState.AddModelError(ModelStateUserNameKey, TextMessages.UnableToLoginWithYourPreferredOpenIDProvider);
                }
                else if (response.Status == AuthenticationStatus.Authenticated)
                {
                    string         userName = response.ClaimedIdentifier;
                    ClaimsResponse fetch    = response.GetExtension <ClaimsResponse>();

                    // Some of the Provider does not return Email
                    // Such as Yahoo, Blogger, Bloglines etc, in that case email will be null
                    string email = (fetch != null) ? fetch.Email : null;

                    UserResult result = userService.Save(userName, email);
                    ModelState.Merge(result.RuleViolations);

                    if (ModelState.IsValid)
                    {
                        bool persistCookie = cookie.GetValue <bool>(CookieRememberMe);

                        formsAuthentication.SetAuthenticationCookie(userName, persistCookie);

                        string returnUrl = cookie.GetValue <string>(CookieReturnUrl);

                        return(Redirect(returnUrl ?? Url.Home()));
                    }
                }
            }

            return(View());
        }
Example #5
0
        public ThemeEntity GetCurrentTheme()
        {
            var         id    = _cookie.GetValue <string>(PreViewCookieName);
            ThemeEntity theme = null;

            if (id.IsNotNullAndWhiteSpace() && (_httpContextAccessor.HttpContext.User?.Identity.IsAuthenticated ?? false))
            {
                theme = Get(id);
                if (theme != null)
                {
                    theme.IsPreView = true;
                }
            }
            return(theme ?? Get(m => m.IsActived == true).FirstOrDefault());
        }
        public string GetCode()
        {
            string code = _cookie.GetValue <string>(CookieName);

            if (code.IsNotNullAndWhiteSpace())
            {
                try
                {
                    return(dataProtector.Unprotect(Base64StringDecode(code)));
                }
                catch
                {
                    return(string.Empty);
                }
            }
            return(string.Empty);
        }
Example #7
0
 public IActionResult Paste(WidgetBase widget)
 {
     widget.ID = _cookie.GetValue <string>(Const.CopyWidgetCookie);
     return(AppendWidget(widget));
 }
Example #8
0
 public IActionResult Design(string ID)
 {
     ViewBag.CanPasteWidget = _cookie.GetValue <string>(Const.CopyWidgetCookie).IsNotNullAndWhiteSpace();
     return(View());
 }
Example #9
0
 public void CancelPreview()
 {
     _cookie.GetValue <string>(PreViewCookieName, true);
 }