public JsonResult LogAppDeletedEvent(string instaceId, string wixSiteUrl) { var success = false; try { var additionalData = "instance Id = " + instaceId + " ; Wix Site Url = " + wixSiteUrl; success = EventLoggerService.Report(new ReportToken { UserId = CurrentUserId, EventType = CommonEnums.eUserEvents.WIX_APP_DELETED, NetSessionId = Session.SessionID, AdditionalMiscData = additionalData, HostName = GetReferrer() }); string error; WidgetEndpointServices.UninstallPlugin(instaceId, out error); return(Json(new JsonResponseToken { success = success }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new JsonResponseToken { success = success, error = Utils.FormatError(ex) }, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage Install(string uid, byte?type, string pluginVersion, string domain) { Logger.Debug(String.Format("PLUGIN INSTALL MSG::uid = {0}::type = {1}::domain {2}", uid, type, domain)); if (type == null || String.IsNullOrEmpty(uid)) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } var pluginType = Utils.ParseEnum <PluginEnums.ePluginType>(type.ToString()); var token = new PluginInstallationDTO { Uid = uid, Type = pluginType, Domain = domain }; string error; var result = WidgetEndpointServices.SavePluginInstallaltion(token, out error); if (result) { SaveUserEvent(CommonEnums.eUserEvents.PLUGIN_INSTALLATION, Utils.GetEnumDescription(pluginType) + " plugin installed::" + uid, uid); } Logger.Debug(String.Format("PLUGIN INSTALL MSG::installed{3}::uid = {0}::type = {1}::domain {2}", uid, type, domain, result)); return(new HttpResponseMessage(result ? HttpStatusCode.OK : HttpStatusCode.InternalServerError)); }
public ActionResult SavePluginOwner(string id) { var error = String.IsNullOrEmpty(id) ? "UID Required" : null; var token = new PluginIndexToken { Uid = id }; if (error == null) { var result = WidgetEndpointServices.VerifyPluginOwner(id, out error); if (result) { token.IsValid = true; return(View("Welcome", token)); } } _mainAccountController.SignUserOut(); token.IsValid = false; token.Message = error; return(View("Index", token)); }
public HttpResponseMessage UnInstall(string uid) { Logger.Debug(String.Format("PLUGIN UNINSTALL MSG::uid = {0}", uid)); if (String.IsNullOrEmpty(uid)) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } string error; var result = WidgetEndpointServices.UninstallPlugin(uid, out error); Logger.Debug(String.Format("PLUGIN UNINSTALL MSG::installed{0}::uid = {1}", result, uid)); return(new HttpResponseMessage(result ? HttpStatusCode.OK : HttpStatusCode.InternalServerError)); }
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)); }
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()); }
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()); }
public ActionResult AppSettingsNew(string instance, string origCompId, string compId) { var user = this.CurrentUser(); if (user == null) { return(RedirectToAction("Index", "Home", new { area = "WixEndPoint", instance = instance, compId = compId, origCompId = origCompId })); } var wixInstance = GetInstanceDto(instance); if (instance != null) { #region save plugin var token = new PluginInstallationDTO { Uid = wixInstance.instanceId.ToString(), Type = PluginEnums.ePluginType.WIX }; string error; if (WidgetEndpointServices.SavePluginInstallaltion(token, out error)) { SaveUserEvent(CommonEnums.eUserEvents.PLUGIN_INSTALLATION, Utils.GetEnumDescription(PluginEnums.ePluginType.WIX) + " plugin installed::" + wixInstance.instanceId, wixInstance.instanceId.ToString()); } #endregion var wixUser = UserServices.FindUserDtoByWixInstanceId(wixInstance.instanceId); if (wixUser != null && user.UserId != wixUser.UserId) { var returnUrl = Url.ToWixLoginHandlerUrl(wixInstance.instanceToken, compId, origCompId); return(RedirectToAction("ForceWixUserSignIn", "Account", new { area = "", returnUrl, email = wixUser.Email, userProfileId = wixUser.UserProfileId, trackingId = wixInstance.instanceId.ToString() })); } #region update plugin owner WidgetEndpointServices.VerifyPluginOwner(wixInstance.instanceId.ToString(), out error); #endregion } var webStore = WidgetServices.GetWidgetStoreDto(wixInstance.instanceId.ToString()) ?? UserServices.GetAndUpdateZombieStore(wixInstance.instanceId, user.UserId); //check for zombie store (if user had store and clicked disconnect and than reconnected) var settingToken = new SettingsViewToken { Instance = wixInstance, UserId = user.UserId, StoreId = webStore != null ? webStore.WebStoreID : (int?)null, UserCoursesList = CoursesServices.GetAuthorCoursesList(Constants.DEFAULT_CURRENCY_ID, user.UserId) }; if (webStore == null)//create a new store { var jsonToken = new WixSettingsJsonToken { cbIsShowBorder = false, cbIsShowTitleBar = true, cbIsTransparent = false, cpBackgroundColor = "#FFFFFF", cpFontColor = "#000000", cpTabsFontColor = "#006699", InstanceId = wixInstance.instanceId.ToString(), StoreId = null, txtStoreName = "", UniqueId = "", WixSiteUrl = "" }; string error; WebstoreWixService.UpdateWixSettings(ref jsonToken, this.CurrentUser(), out error); settingToken.StoreName = jsonToken.txtStoreName; settingToken.FontColor = jsonToken.cpFontColor; settingToken.TabsFontColor = jsonToken.cpTabsFontColor; settingToken.BackgroundColor = jsonToken.cpBackgroundColor; settingToken.IsTransparent = jsonToken.cbIsTransparent; settingToken.IsShowBorder = jsonToken.cbIsShowBorder; settingToken.IsShowTitleBar = jsonToken.cbIsShowBorder; settingToken.StoreId = jsonToken.StoreId; settingToken.UniqueId = jsonToken.UniqueId; } else { settingToken.StoreName = webStore.WebStoreName; settingToken.FontColor = webStore.FontColor; settingToken.TabsFontColor = webStore.TabsFontColor; settingToken.BackgroundColor = webStore.BackgroundColor; settingToken.IsTransparent = webStore.IsTransParent; settingToken.IsShowBorder = webStore.IsShowBorder; settingToken.IsShowTitleBar = webStore.IsShowTitleBar; settingToken.StoreId = webStore.WebStoreID; settingToken.UniqueId = webStore.UniqueId; // settingToken.StoreCoursesIds = WidgetServices.GetAllStoreCourseIds(webStore.WebStoreID); } return(View(settingToken)); }