Example #1
0
        public ActionResult Index(string id)
        {
            var token = new PluginIndexToken();

            if (String.IsNullOrEmpty(id))
            {
                token.IsValid = false;
                token.Message = "InstallationId required";

                return(View(token));
            }

            string error;
            var    plugin = WidgetEndpointServices.GetPluginInstallationDto(id, out error);

            if (plugin == null)
            {
                token.IsValid = false;
                token.Message = error;

                return(View(token));
            }

            var registrationType = Utils.ParseEnum <CommonEnums.eRegistrationSources>(plugin.Type.ToString());

            token.RegistrationSource = registrationType;
            token.Uid     = id;
            token.IsValid = true;

            if (!User.Identity.IsAuthenticated)
            {
                return(View(token));
            }

            if (plugin.UserId != null && plugin.UserId == CurrentUserId)
            {
                return(View("Welcome", new PluginIndexToken {
                    IsValid = true, Uid = id
                }));
            }

            _mainAccountController.SignUserOut();
            return(View(token));
        }
Example #2
0
        public ActionResult SaveNewStore(BaseWebStoreDTO token, string uid, int?srcId, string callback)
        {
            string error;

            token.StoreId = -1;

            //check source
            var plugin = WidgetEndpointServices.GetPluginInstallationDto(uid, out error);

            if (plugin != null)
            {
                token.RegistrationSource = plugin.Type.PluginType2RegistrationSource();
            }

            var saved = _pluginStoreServices.SaveStore(ref token, CurrentUserId, srcId, out error);

            ViewBag.result = JsSerializer.Serialize(new JsonResponseToken {
                success = saved, error = error
            });
            ViewBag.callback     = callback;
            Response.ContentType = "text/javascript";
            return(View());
        }
Example #3
0
        public ActionResult UserScript(string callback, string uid)
        {
            ViewBag.linkMessage = "null";
            ViewBag.linkUrl     = "null";
            var     currencies     = JsSerializer.Serialize(_geoServices.ActiveCurrenciesList);
            dynamic stores         = new BaseWebStoreDTO[0];
            var     userAuthorized = false;
            string  error;
            var     installToken = WidgetEndpointServices.GetPluginInstallationDto(uid, out error);

            //Logger.Debug("Call plugin user script for " + uid);

            if (installToken == null)
            {
                ViewBag.linkMessage = "'Installation not registered with " + error + ". Please contact support team.'";
                ViewBag.linkUrl     = "'#'";
            }
            else
            {
                if (CurrentUserId < 0)
                {
                    ViewBag.linkMessage = installToken.UserId == null ? "'Oooooppss… No LFE account is connected to this plugin. Click here to connect an LFE account with this plugin'" : "'Oooooppss… You are not logged in. Click here to login with the LFE account associated with this plugin'";
                    ViewBag.linkUrl     = "'#login'";
                }
                else
                {
                    if (installToken.UserId != null)
                    {
                        if (installToken.UserId == CurrentUserId)
                        {
                            stores         = WidgetEndpointServices.GetOwnerStores(CurrentUserId).OrderBy(x => x.Name).ToArray();
                            userAuthorized = true;
                            //show panel
                        }
                        else
                        {
                            ViewBag.linkMessage = "'Oooooppss… You are attempting to login with an LFE account that is not connected to this application. Click here to connect with the LFE account associated with this plugin'";
                            ViewBag.linkUrl     = "'#'";
                        }
                    }
                    else
                    {
                        // Show message"Connect account"
                        ViewBag.linkMessage = "'Oooooppss… No LFE account is connected to this application. Click here to connect your LFE account'";
                        ViewBag.linkUrl     = "'#'";
                    }
                }
            }

            var newStore = new BaseWebStoreDTO
            {
                StoreId             = -1
                , TrackingID        = Guid.NewGuid().ToString()
                , DefaultCurrencyId = Constants.DEFAULT_CURRENCY_ID
            };



            ViewBag.currencies   = string.IsNullOrEmpty(currencies) ? "[]" : currencies;
            ViewBag.stores       = JsSerializer.Serialize(stores);
            ViewBag.user         = CurrentUserId;
            ViewBag.newStore     = JsSerializer.Serialize(newStore);
            ViewBag.callback     = callback;
            ViewBag.uid          = uid;
            ViewBag.status       = userAuthorized ? string.Empty : HttpStatusCode.Forbidden.ToString();
            Response.ContentType = "text/javascript";
            return(View());
        }