protected void Page_Load(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { Response.Redirect("CreateOrder1.aspx"); } _Basket = _User.Basket; // INITIALIZE INVENTORY VARIABLES _InventoryManager = AbleContext.Resolve <IInventoryManager>(); _StoreInventoryEnabled = AbleContext.Current.Store.Settings.EnableInventory; // SHOW QUANTITY AVAILABLE COLUMN IF INVENTORY IS ENABLED BasketGrid.Columns[4].Visible = _StoreInventoryEnabled; // INITIALIZE THE CAPTION string userName = _User.IsAnonymous ? "Unregistered User" : _User.UserName; Caption.Text = string.Format(Caption.Text, userName); // SEE IF THE ADD PRODUCT FORM SHOULD BE VISIBLE int productId = AlwaysConvert.ToInt(Request.Form[AddProductId.UniqueID]); Product product = ProductDataSource.Load(productId); if (product != null) { ShowProductForm(product); } }
protected void Page_Init(object sender, EventArgs e) { _SubscriptionId = AlwaysConvert.ToInt(Request.QueryString["SubscriptionId"]); _UserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); _User = UserDataSource.Load(_UserId); CountryCode.DataSource = CountryDataSource.LoadAll("Name"); CountryCode.DataBind(); //INIT ADDRESS Address address = _User.PrimaryAddress; FirstName.Text = address.FirstName; LastName.Text = address.LastName; Company.Text = address.Company; Address1.Text = address.Address1; Address2.Text = address.Address2; City.Text = address.City; Province.Text = address.Province; PostalCode.Text = address.PostalCode; ListItem selectedCountry = CountryCode.Items.FindByValue(AbleContext.Current.Store.DefaultWarehouse.CountryCode); if (!String.IsNullOrEmpty(address.CountryCode)) { selectedCountry = CountryCode.Items.FindByValue(address.CountryCode.ToString()); } if (selectedCountry != null) { CountryCode.SelectedIndex = CountryCode.Items.IndexOf(selectedCountry); } Phone.Text = address.Phone; Fax.Text = address.Fax; Residence.SelectedIndex = (address.Residence ? 0 : 1); }
protected void LoginButton_Click(object sender, EventArgs e) { if (Membership.ValidateUser(UserName.Text, Password.Text)) { //MIGRATE USER IF NEEDED int newUserId = UserDataSource.GetUserId(UserName.Text); if ((AbleContext.Current.UserId != newUserId) && (newUserId != 0)) { User.Migrate(AbleContext.Current.User, UserDataSource.Load(newUserId)); AbleContext.Current.UserId = newUserId; AbleContext.Current.User = UserDataSource.Load(newUserId); } //HANDLE LOGIN PROCESSING if (RememberUserName.Checked) { HttpCookie cookie = new HttpCookie("UserName", UserName.Text); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies.Add(new HttpCookie("UserName", "")); } //UPDATE AUTHORIZATION COOKIE FormsAuthentication.SetAuthCookie(UserName.Text, false); //REDIRECT TO CHECKOUT Response.Redirect(AbleCommerce.Code.NavigationHelper.GetCheckoutUrl(true)); } else { InvalidLogin.IsValid = false; } }
protected void Page_Init(object sender, EventArgs e) { _userId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); _User = UserDataSource.Load(_userId); CountryCode.DataSource = CountryDataSource.LoadAll("Name"); CountryCode.DataBind(); BindShippingAddresses(true); }
protected void Page_Init(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { Response.Redirect("CreateOrder1.aspx"); } _Basket = _User.Basket; MiniBasket1.BasketId = _Basket.Id; // ENSURE THE BASKET IS PACKAGED IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>(); preCheckoutService.Package(_Basket); // INITIALIZE THE CAPTION string userName = _User.IsAnonymous ? "Unregistered User" : _User.UserName; Caption.Text = string.Format(Caption.Text, userName); //INITIALIZE BILLING COUNTRY LIST ON EVERY VISIT InitializeBillingCountryAndProvince(); // INITIALIZE SHIPPING CONTROLS trAddressBook.Visible = _Basket.Items.HasShippableProducts(); if (trAddressBook.Visible) { // THESE TASKS MUST OCCUR EVER VISIT DUE TO DISABLED VIEWSTATE InitializeAddressBook(); InitializeShippingCountryAndProvince(); // SEE IF WE NEED TO SHOW THE SHIPPING OFORM int shipAddressId = GetShippingAddressId(); if (shipAddressId == 0 || shipAddressId == _User.PrimaryAddress.Id) { // SHIP TO BILLING ADDRESS ShipAddressPanel.Visible = false; trContinueButton1.Visible = true; BillAddressPanel.DefaultButton = "ContinueButton"; } else { // INITIALIZE SHIPPING ADDRESS ShipAddressPanel.Visible = true; trContinueButton1.Visible = false; BillAddressPanel.DefaultButton = "ContinueButton2"; } } // POPULATE BILLING FORM ON FIRST PAGE VISIT if (!Page.IsPostBack) { InitializeBillingAddress(); } }
protected void Page_Load(object sender, EventArgs e) { _UserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); user = UserDataSource.Load(_UserId); if (user == null) { Response.Redirect("~/Admin/"); } Caption.Text = string.Format(Caption.Text, (user.IsAnonymous ? "anonymous" : user.UserName)); }
protected void Page_Init(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { return; } _Basket = _User.Basket; }
protected void LoginUserButton_Click(object sender, EventArgs e) { int newUserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); User user = UserDataSource.Load(newUserId); if ((user != null) && (user.Id != AbleContext.Current.UserId) && (!user.IsAdmin)) { //LOGIN AS USER AND SEND TO THE STORE HOME PAGE FormsAuthentication.SetAuthCookie(user.UserName, false); Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl()); } }
private void AsycnSendEmails(int storeId, int userId, MailMessage[] messages) { //REINITIALIZE THE TOKEN WITH SAVED STORE/USER CONTEXT Store store = StoreDataSource.Load(storeId); if (store != null) { Token.Instance.InitStoreContext(store); User user = UserDataSource.Load(userId); Token.Instance.InitUserContext(user); SendEmails(messages); } }
protected void UserGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Login") { int newUserId = AlwaysConvert.ToInt(e.CommandArgument); User user = UserDataSource.Load(newUserId); if ((user != null) && (user.Id != AbleContext.Current.UserId) && (!user.IsAdmin)) { //LOGIN AS USER AND SEND TO THE STORE HOME PAGE FormsAuthentication.SetAuthCookie(user.UserName, false); Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl()); } } }
protected void NewUserButton_Click(object sender, EventArgs e) { // SEE IF WE HAVE AN ANONYMOUS USER MARKED IN THE SESSION User user = UserDataSource.Load(AlwaysConvert.ToInt(Session["CreateOrder_AnonUserId"])); if (user == null) { // CREATE A NEW ANONYMOUS USER AND BASKET FOR THIS ORDER user = UserDataSource.CreateUserInstance(); user.Save(); user.Basket.Save(); Session["CreateOrder_AnonUserId"] = user.Id; } Response.Redirect("CreateOrder2.aspx?UID=" + user.Id); }
protected void UserGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { NewUserId.Value = AlwaysConvert.ToInt(e.CommandArgument).ToString(); User newUser = UserDataSource.Load(AlwaysConvert.ToInt(NewUserId.Value)); if (newUser != null) { string oldUserName = _Order.User == null ? _Order.BillToEmail + "(user deleted)" : _Order.User.UserName; DialogCaption.Text = string.Format(DialogCaption.Text, _Order.OrderNumber.ToString(), newUser.UserName); DialogInstructionText.Text = string.Format(DialogInstructionText.Text, _Order.BillToEmail, newUser.UserName); TransferPopup.Show(); } } }
protected void Page_Init(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { return; } _Basket = _User.Basket; UpdateValidationOptions(); trRoutingNumber.Visible = (_User.PrimaryAddress.CountryCode == "US"); trSortCode.Visible = !trRoutingNumber.Visible; }
protected void Page_Load(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { // UNKNOWN USER, HIDE THIS CONTROL this.Controls.Clear(); } else { _Basket = _User.Basket; CouponCode.Attributes.Add("autocomplete", "off"); } }
protected void Page_Load(object sender, EventArgs e) { _UserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); if (!Page.IsPostBack) { User user = UserDataSource.Load(_UserId); BasketItemsGrid.DataSource = user.Basket.Items; BasketItemsGrid.DataBind(); EditBasketLink.NavigateUrl += _UserId; // HIDE THE CREATE ORDER OPTION IF THE USER IS ANONYMOUS if (user.IsAnonymous) { EditBasketLink.Visible = false; } } }
protected void IsInGroup_CheckedChanged(object sender, EventArgs e) { CheckBox isInGroup = (CheckBox)sender; GridViewRow row = (GridViewRow)isInGroup.NamingContainer; GridView grid = row.NamingContainer as GridView; int dataItemIndex = (row.DataItemIndex - (grid.PageSize * grid.PageIndex)); int userId = (int)grid.DataKeys[dataItemIndex].Value; User user = UserDataSource.Load(userId); CommerceBuilder.Users.Group group = GroupDataSource.Load(_GroupId); UserGroup userGroup = UserGroupDataSource.Load(user.Id, group.Id); if (userGroup == null) { userGroup = new UserGroup(user, group); } int index = user.UserGroups.IndexOf(userGroup); if (isInGroup.Checked) { //IN ROLE WAS CHECKED, ADD ROLE IF NOT FOUND if (index < 0) { user.UserGroups.Add(userGroup); user.UserGroups.Save(); AbleContext.Current.Database.FlushSession(); } } else { //IN ROLE WAS UNCHECKED, DELETE ROLE IF FOUND if (index > -1) { user.UserGroups.DeleteAt(index); } } //REBIND GRIDS BindSearchPanel(); }
protected void Page_Init(object sender, EventArgs e) { _UserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); _User = UserDataSource.Load(_UserId); if (_User == null) { Response.Redirect("Default.aspx"); } if (!string.IsNullOrEmpty(Request.QueryString["Tab"])) { _tabIndex = AlwaysConvert.ToInt(Request.QueryString["Tab"]); if (_tabIndex > 0 && _tabIndex <= Tabs.Tabs.Count) { Tabs.ActiveTabIndex = _tabIndex - 1; } } // ONLY SECURITY ADMINS CAN EDIT ADMIN USERS if (_User.IsAdmin && (AbleContext.Current.User.Id != _User.Id && !AbleContext.Current.User.IsSecurityAdmin)) { Response.Redirect("Default.aspx"); } // NON SUPER USERS CANNOT EDIT SUPER USERS ACCOUNT if (_User.IsSystemAdmin && !AbleContext.Current.User.IsSystemAdmin) { Response.Redirect("Default.aspx"); } // INITIALIZE CAPTION Caption1.Text = string.Format(Caption1.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); Caption2.Text = string.Format(Caption2.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); Caption3.Text = string.Format(Caption3.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); Caption4.Text = string.Format(Caption4.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); Caption5.Text = string.Format(Caption5.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); Caption6.Text = string.Format(Caption6.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); Caption7.Text = string.Format(Caption7.Text, _User.IsAnonymous ? "anonymous" : _User.UserName); }
public static PaymentMethodCollection LoadForUser(int userId, string sortExpression) { //DEFAULT SORT EXPRESSION if (string.IsNullOrEmpty(sortExpression)) { sortExpression = "OrderBy"; } //LOAD THE PAYMENT METHODS FOR THE STORE PaymentMethodCollection allMethods = PaymentMethodDataSource.LoadForStore(sortExpression); //LOAD THE USER TO OBTAIN ROLES User user = UserDataSource.Load(userId); //CREATE FILTERED LIST OF PAYMENT METHODS PaymentMethodCollection filteredMethods = new PaymentMethodCollection(); foreach (PaymentMethod method in allMethods) { if (method.UserHasAccess(user)) { filteredMethods.Add(method); } } return(filteredMethods); }
protected void Page_Init(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { Response.Redirect("CreateOrder1.aspx"); } _Basket = _User.Basket; MiniBasket1.BasketId = _Basket.Id; if (!Page.IsPostBack) { IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>(); preCheckoutService.Recalculate(_Basket); } // INITIALIZE THE CAPTION string userName = _User.IsAnonymous ? "Unregistered User" : _User.UserName; Caption.Text = string.Format(Caption.Text, userName); // SHOW BILLING ADDRESS BillToAddress.Text = _User.PrimaryAddress.ToString(true); EditAddressesLink.NavigateUrl += "?UID=" + _UserId; // SHOW REGISTRATION PANEL IF USER IS ANONYMOUS if (_User.IsAnonymous) { RegisterPanel.Visible = true; string billToEmail = _User.PrimaryAddress.Email; IList <User> matchingUsers = UserDataSource.LoadForEmail(billToEmail, false); bool userExists = (matchingUsers.Count > 0); if (userExists) { _ExistingUser = matchingUsers[0]; AccountUserName.Text = _ExistingUser.UserName; AccountEmail.Text = _ExistingUser.Email; } else { AccountUserName.Text = billToEmail; AccountEmail.Text = billToEmail; } RegisteredUserHelpText.Visible = userExists; UnregisteredUserHelpText.Visible = !userExists; LinkAccountLabel.Visible = userExists; CreateAccountLabel.Visible = !userExists; trAccountPassword.Visible = !userExists; trForceExpiration.Visible = !userExists; } // SHOW SHIPPING METHODS IF NECESSARY ShippingMethodPanel.Visible = _Basket.Items.HasShippableProducts(); if (ShippingMethodPanel.Visible) { tdShipTo.Visible = true; Address shipAddress = this.ShippingAddress; if (shipAddress != null) { ShipToAddress.Text = shipAddress.ToString(true); } if (!Page.IsPostBack) { // ONLY BIND SHIPMENT LIST ON FIRST VISIT ShipmentList.DataSource = _Basket.Shipments; ShipmentList.DataBind(); } } }
protected void Page_Init(object sender, EventArgs e) { _UserId = AlwaysConvert.ToInt(Request.QueryString["Key"]); _User = UserDataSource.Load(_UserId); if ((_User == null) || (!_User.IsApproved)) { Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl()); } string tempPassword = AlwaysConvert.ToString(Request.QueryString["Check"]); if (string.IsNullOrEmpty(tempPassword) || (_User.Comment != tempPassword)) { Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl()); } if (!Page.IsPostBack) { // CHECK IF THERE IS ALREADY A USER WITH DESIRED USERNAME if (_User.IsAnonymousOrGuest && UserDataSource.GetUserIdByUserName(_User.Email) == 0) { UserName.Text = _User.Email; } else { UserName.Text = _User.UserName; } // PASSWORD POLICY PasswordPolicy policy; if (_User.IsAdmin) { policy = new MerchantPasswordPolicy(); } else { policy = new CustomerPasswordPolicy(); } PasswordPolicyLength.Text = string.Format(PasswordPolicyLength.Text, policy.MinLength); PasswordPolicyHistoryCount.Visible = (policy.HistoryCount > 0); if (PasswordPolicyHistoryCount.Visible) { PasswordPolicyHistoryCount.Text = string.Format(PasswordPolicyHistoryCount.Text, policy.HistoryCount); } PasswordPolicyHistoryDays.Visible = (policy.HistoryDays > 0); if (PasswordPolicyHistoryDays.Visible) { PasswordPolicyHistoryDays.Text = string.Format(PasswordPolicyHistoryDays.Text, policy.HistoryDays); } List <string> requirements = new List <string>(); if (policy.RequireUpper) { requirements.Add("uppercase letter"); } if (policy.RequireLower) { requirements.Add("lowercase letter"); } if (policy.RequireNumber) { requirements.Add("number"); } if (policy.RequireSymbol) { requirements.Add("symbol"); } if (!policy.RequireNumber && !policy.RequireSymbol && policy.RequireNonAlpha) { requirements.Add("non-letter"); } PasswordPolicyRequired.Visible = (requirements.Count > 0); if (PasswordPolicyRequired.Visible) { if (requirements.Count > 1) { requirements[requirements.Count - 1] = "and " + requirements[requirements.Count - 1]; } PasswordPolicyRequired.Text = string.Format(PasswordPolicyRequired.Text, string.Join(", ", requirements.ToArray())); } } }
protected void Page_Init(object sender, EventArgs e) { // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]); _User = UserDataSource.Load(_UserId); if (_User == null) { return; } _Basket = _User.Basket; UpdateValidationOptions(); //SET THE DEFAULT NAME CardName.Text = _User.PrimaryAddress.FullName; //POPULATE EXPIRATON DATE DROPDOWN int thisYear = LocaleHelper.LocalNow.Year; for (int i = 0; (i <= 10); i++) { ExpirationYear.Items.Add(new ListItem((thisYear + i).ToString())); } //POPULATE START DATE DROPDOWN for (int i = 1997; (i <= thisYear); i++) { StartDateYear.Items.Add(new ListItem(i.ToString())); } //LOAD AVAILABLE PAYMENT METHODS IList <PaymentMethod> methods = AbleCommerce.Code.StoreDataHelper.GetPaymentMethods(_UserId); List <string> creditCards = new List <string>(); List <string> intlDebitCards = new List <string>(); foreach (PaymentMethod method in methods) { if (method.IsCreditOrDebitCard()) { CardType.Items.Add(new ListItem(method.Name, method.Id.ToString())); if (method.IsIntlDebitCard()) { intlDebitCards.Add(method.Name); } else { creditCards.Add(method.Name); } } } //HIDE THIS CONTROL IF THERE ARE NO CREDIT CARD PAYMENT METHODS if (CardType.Items.Count == 1) { Trace.Write(this.GetType().ToString(), "Output suppressed, no credit card payment methods detected."); this.Controls.Clear(); } else { //SHOW OR HIDE INTL DEBIT FIELDS if (intlDebitCards.Count > 0) { trIntlCVV.Visible = true; if (creditCards.Count > 0) { IntlCVVCredit.Visible = true; IntlCVVCredit.Text = string.Format(IntlCVVCredit.Text, FormatCardNames(creditCards)); } else { IntlCVVCredit.Visible = false; } IntlCVVDebit.Text = string.Format(IntlCVVDebit.Text, FormatCardNames(intlDebitCards)); SecurityCodeValidator.Enabled = false; trIntlInstructions.Visible = true; IntlInstructions.Text = string.Format(IntlInstructions.Text, FormatCardNames(intlDebitCards)); trIssueNumber.Visible = true; trStartDate.Visible = true; } else { trIntlCVV.Visible = false; trIntlInstructions.Visible = false; trIssueNumber.Visible = false; trStartDate.Visible = false; } } }
private void ProcessRules(BreadCrumbItem breadCrumbItem) { int id; if (breadCrumbItem.Url == "#") { return; } switch (breadCrumbItem.Url.ToLowerInvariant()) { case "~/admin/orders/shipments/editshipment.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); breadCrumbItem.Url += "?OrderShipmentId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, id); break; case "~/admin/products/editproduct.aspx": case "~/admin/products/variants/variants.aspx": case "~/admin/products/variants/options.aspx": case "~/admin/products/digitalgoods/digitalgoods.aspx": case "~/admin/products/kits/editkit.aspx": case "~/admin/products/assets/images.aspx": case "~/admin/products/editproducttemplate.aspx": case "~/admin/products/specials/default.aspx": int categoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); id = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(id); if (categoryId > 0) { breadCrumbItem.Url += "?CategoryId=" + categoryId + "&ProductId=" + id; } else { breadCrumbItem.Url += "?ProductId=" + id; } breadCrumbItem.Title = string.Format(breadCrumbItem.Title, product.Name); break; case "~/admin/orders/vieworder.aspx": case "~/admin/orders/edit/editorderitems.aspx": case "~/admin/orders/viewdigitalgoods.aspx": case "~/admin/orders/payments/default.aspx": case "~/admin/orders/shipments/default.aspx": id = AbleCommerce.Code.PageHelper.GetOrderId(); Order order = OrderDataSource.Load(id); breadCrumbItem.Url += "?OrderNumber=" + order.OrderNumber; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, order.OrderNumber); break; case "~/admin/marketing/coupons/editcoupon.aspx": id = AlwaysConvert.ToInt(Request.QueryString["CouponId"]); Coupon coupon = CouponDataSource.Load(id); breadCrumbItem.Url += "?CouponId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, coupon.Name); break; case "~/admin/products/variants/editoption.aspx": case "~/admin/products/variants/editchoices.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OptionId"]); Option option = OptionDataSource.Load(id); breadCrumbItem.Url += "?OptionId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, option.Name); break; case "~/admin/products/giftwrap/editwrapgroup.aspx": id = AlwaysConvert.ToInt(Request.QueryString["WrapGroupId"]); WrapGroup wrapGroup = WrapGroupDataSource.Load(id); breadCrumbItem.Url += "?WrapGroupId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, wrapGroup.Name); break; case "~/admin/marketing/email/managelist.aspx": id = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]); EmailList emailList = EmailListDataSource.Load(id); if (emailList != null) { breadCrumbItem.Url += "?EmailListId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, emailList.Name); } break; case "~/admin/marketing/discounts/editdiscount.aspx": id = AlwaysConvert.ToInt(Request.QueryString["VolumeDiscountId"]); VolumeDiscount discount = VolumeDiscountDataSource.Load(id); breadCrumbItem.Url += "?VolumeDiscountId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, discount.Name); break; case "~/admin/catalog/editwebpage.aspx": id = AbleCommerce.Code.PageHelper.GetWebpageId(); Webpage webpage = WebpageDataSource.Load(id); breadCrumbItem.Url += "?WebpageId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, webpage.Name); break; case "~/admin/catalog/editLink.aspx": id = AbleCommerce.Code.PageHelper.GetLinkId(); Link link = LinkDataSource.Load(id); breadCrumbItem.Url += "?LinkId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, link.Name); break; case "~/admin/people/users/edituser.aspx": id = AlwaysConvert.ToInt(Request.QueryString["UserId"]); User user = UserDataSource.Load(id); breadCrumbItem.Url += "?UserId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, user.UserName); break; case "~/admin/digitalgoods/editdigitalgood.aspx": case "~/admin/digitalgoods/serialkeyproviders/defaultprovider/configure.aspx": id = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); DigitalGood dg = DigitalGoodDataSource.Load(id); if (dg != null) { breadCrumbItem.Url += "?DigitalGoodId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, dg.Name); } break; case "~/admin/products/producttemplates/editproducttemplate.aspx": id = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]); ProductTemplate template = ProductTemplateDataSource.Load(id); if (template == null) { InputField field = InputFieldDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["InputFieldId"])); if (field != null) { template = field.ProductTemplate; id = template.Id; } } if (template != null) { breadCrumbItem.Url += "?ProductTemplateId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, template.Name); } else { } break; case "~/admin/reports/dailyabandonedbaskets.aspx": id = AlwaysConvert.ToInt(Request.QueryString["BasketId"]); Basket basket = BasketDataSource.Load(id); if (basket != null) { breadCrumbItem.Url += "?ReportDate=" + basket.User.LastActivityDate.Value.ToShortDateString(); } break; } // resolve relative urls if (breadCrumbItem.Url.StartsWith("~/")) { breadCrumbItem.Url = Page.ResolveUrl(breadCrumbItem.Url); } }
protected void LoginButton_Click(object sender, EventArgs e) { _LastPasswordValue = Password.Text; if (Page.IsValid) { //VALIDATE CAPTCHA if (!trCaptchaField.Visible || (CaptchaImage.Authenticate(CaptchaInput.Text))) { if (Membership.ValidateUser(UserName.Text, Password.Text)) { //MIGRATE USER IF NEEDED int newUserId = UserDataSource.GetUserId(UserName.Text); if ((AbleContext.Current.UserId != newUserId) && (newUserId != 0)) { CommerceBuilder.Users.User.Migrate(AbleContext.Current.User, UserDataSource.Load(newUserId)); AbleContext.Current.UserId = newUserId; } //HANDLE LOGIN PROCESSING if (RememberUserName.Checked) { HttpCookie cookie = new HttpCookie("UserName", UserName.Text); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies.Add(new HttpCookie("UserName", "")); } // CHECK PASSWORD FOR EXPIRATION User newUser = UserDataSource.Load(newUserId); MerchantPasswordPolicy policy = new MerchantPasswordPolicy(); if (policy.IsPasswordExpired(newUser)) { ShowPasswordExpired(); } else { // LOGIN SUCCESSFUL, REDIRECT FormsAuthentication.RedirectFromLoginPage(UserName.Text, false); } } else { User user = UserDataSource.LoadForUserName(UserName.Text); if (user != null) { if (!user.IsApproved) { AccountDisabled.IsValid = false; } else { MerchantPasswordPolicy policy = new MerchantPasswordPolicy(); int remainingTries = policy.MaxAttempts - user.FailedPasswordAttemptCount; if (!user.IsLockedOut && remainingTries > 0) { InvalidLogin.ErrorMessage += " You have {0} tries remaining."; InvalidLogin.ErrorMessage = String.Format(InvalidLogin.ErrorMessage, remainingTries); InvalidLogin.IsValid = false; } else { AccountLocked.ErrorMessage = String.Format(AccountLocked.ErrorMessage, policy.LockoutPeriod); AccountLocked.IsValid = false; } } } else { InvalidLogin.IsValid = false; } RefreshCaptcha(); } } else { CustomValidator invalidInput = new CustomValidator(); invalidInput.ValidationGroup = "Login"; invalidInput.Text = "*"; invalidInput.ErrorMessage = "You did not input the verification number correctly."; invalidInput.IsValid = false; phCaptchaValidators.Controls.Add(invalidInput); RefreshCaptcha(); } } }
protected void InstallButton_Click(object sender, EventArgs e) { if (Page.IsValid) { // update some settings that we can determine from the script Store store = AbleContext.Current.Store; store.Name = StoreName.Text; store.Save(); store.StoreUrl = GetStoreUrl(); store.Settings.TimeZoneOffset = GetDefaultTzOffset(); store.Settings.TimeZoneCode = store.Settings.TimeZoneOffset.ToString(); // update default store email string defaultEmailAddress = StoreEmail.Text.Trim(); // use admin email if store email is not available if (string.IsNullOrEmpty(defaultEmailAddress)) { defaultEmailAddress = Email.Text.Trim(); } store.Settings.DefaultEmailAddress = defaultEmailAddress; store.Settings.Save(); // update the store address Warehouse warehouse = store.DefaultWarehouse; warehouse.Name = store.Name; warehouse.Address1 = Address1.Text; warehouse.Address2 = Address2.Text; warehouse.City = City.Text; warehouse.Province = Province.Text; warehouse.PostalCode = PostalCode.Text; warehouse.CountryCode = Country.Text; warehouse.Phone = Phone.Text; warehouse.Fax = Fax.Text; warehouse.Email = StoreEmail.Text; warehouse.Save(); // update the admin user User admin = UserDataSource.Load(1); admin.UserName = Email.Text; admin.Email = Email.Text; admin.Save(); admin.SetPassword(Password.Text); // add admin user to default group CommerceBuilder.Users.Group defaultGroup = AbleContext.Container.Resolve <IGroupRepository>() .LoadForName(CommerceBuilder.Users.Group.DefaultUserGroupName); if (defaultGroup != null) { admin.UserGroups.Add(new UserGroup(admin, defaultGroup)); admin.Save(); } Address address = admin.PrimaryAddress; address.Email = Email.Text; address.Address1 = Address1.Text; address.Address2 = Address2.Text; address.City = City.Text; address.Province = Province.Text; address.PostalCode = PostalCode.Text; address.CountryCode = Country.Text; address.Phone = Phone.Text; address.Fax = Fax.Text; address.Save(); // copy email templates string sourceDir = Server.MapPath("~/App_Data/EmailTemplates/Default"); string targetDir = Server.MapPath("~/App_Data/EmailTemplates/1"); Directory.CreateDirectory(targetDir); foreach (var file in Directory.GetFiles(sourceDir)) { File.Copy(file, Path.Combine(targetDir, Path.GetFileName(file)), true); } if (IncludeSampleData.Checked) { // add the sample data to the database string connectionString = ConfigurationManager.ConnectionStrings["AbleCommerce"].ConnectionString; List <string> errorList = RunScript(connectionString, Server.MapPath("~/Install/SampleData.sql")); // extract the sample image and email files CompressionHelper.ExtractArchive(Server.MapPath("~/install/ProductImages.zip"), Server.MapPath("~/Assets/ProductImages")); // generate a sample digital good File.WriteAllText(Server.MapPath("~/App_Data/DigitalGoods/sample.txt"), "This is a sample text file for use with digital delivery."); // check for errors in script if (errorList.Count > 0) { InstallSucceededPanel.Visible = false; InstallErrorPanel.Visible = true; InstallErrorList.Text = "<p>" + string.Join("</p><p>", errorList.ToArray()) + "</p>"; } } // Make SQL the default search provider on new installs (JIRA ISSUE # AC8-1998) ApplicationSettings.Instance.SearchProvider = "SqlSearchProvider"; ApplicationSettings.Instance.Save(); // display complete message FormPanel.Visible = false; InstallCompletePanel.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { _UserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); _User = UserDataSource.Load(_UserId); if (!Page.IsPostBack) { // INITIALIZE LEFT COLUMN WITH ADJUSTABLE ACCOUNT SETTINGS UserName.Text = _User.UserName; Email.Text = _User.Email; IsDisabled.Enabled = (_User.Id != AbleContext.Current.UserId); IsDisabled.Checked = !_User.IsApproved; ListItem selectedItem = TaxExemptionType.Items.FindByValue(((int)_User.TaxExemptionType).ToString()); if (selectedItem != null) { TaxExemptionType.SelectedIndex = TaxExemptionType.Items.IndexOf(selectedItem); } TaxExemptionReference.Text = _User.TaxExemptionReference; } InitializeChangeGroupsJS(); // INITIALIZE RIGHT COLUMN OF PASSWORD DETAILS RegisteredSinceDate.Text = _User.CreateDate.ToString("g"); if (_User.LastActivityDate.HasValue && _User.LastActivityDate > System.DateTime.MinValue) { LastActiveDate.Text = _User.LastActivityDate.Value.ToString("g"); } FailedLoginCount.Text = _User.FailedPasswordAttemptCount.ToString(); if (_User.LastLockoutDate.HasValue && _User.LastLockoutDate > System.DateTime.MinValue) { LastLockoutDate.Text = _User.LastLockoutDate.Value.ToString("g"); } if (_User.Passwords.Count > 0) { TimeSpan ts = LocaleHelper.LocalNow - _User.Passwords[0].CreateDate; string timeSpanPhrase; if (ts.Days > 0) { timeSpanPhrase = ts.Days.ToString() + " days"; } else if (ts.Hours > 0) { timeSpanPhrase = ts.Hours.ToString() + " hours"; } else { timeSpanPhrase = ts.Minutes.ToString() + " minutes"; } PasswordLastChangedText.Text = string.Format(PasswordLastChangedText.Text, timeSpanPhrase); } else { PasswordLastChangedText.Visible = false; } // DISPLAY POLICY ON CHANGE PASSWORD FORM PasswordPolicy policy; if (_User.IsAdmin) { policy = new MerchantPasswordPolicy(); } else { policy = new CustomerPasswordPolicy(); } PasswordPolicyLength.Text = string.Format(PasswordPolicyLength.Text, policy.MinLength); List <string> requirements = new List <string>(); if (policy.RequireUpper) { requirements.Add("uppercase letter"); } if (policy.RequireLower) { requirements.Add("lowercase letter"); } if (policy.RequireNumber) { requirements.Add("number"); } if (policy.RequireSymbol) { requirements.Add("symbol"); } if (!policy.RequireNumber && !policy.RequireSymbol && policy.RequireNonAlpha) { requirements.Add("non-letter"); } PasswordPolicyRequired.Visible = (requirements.Count > 0); if (PasswordPolicyRequired.Visible) { if (requirements.Count > 1) { requirements[requirements.Count - 1] = "and " + requirements[requirements.Count - 1]; } PasswordPolicyRequired.Text = string.Format(PasswordPolicyRequired.Text, string.Join(", ", requirements.ToArray())); } bool showLoginAs = ((_User.Id != AbleContext.Current.UserId) && (!_User.IsAdmin)); if (showLoginAs) { LoginUserButton.Visible = true; LoginUserButton.OnClientClick = string.Format(LoginUserButton.OnClientClick, _User.UserName); } else { LoginUserButton.Visible = false; } }
protected void LoginButton_Click(object sender, EventArgs e) { _LastPasswordValue = Password.Text; User loginUser = UserDataSource.LoadForUserName(UserName.Text); if (loginUser != null) { bool stillNeedsCaptcha = false; if ((loginUser.IsAdmin) && (!trCaptchaField.Visible)) { stillNeedsCaptcha = (new MerchantPasswordPolicy()).ImageCaptcha; } if (!stillNeedsCaptcha) { // IF CAPTCHA IS REQUIRED CHECK IF THE ENTRY IS VALID if ((!trCaptchaField.Visible) || (CaptchaImage.Authenticate(CaptchaInput.Text))) { // CAPTCHA IS HIDDEN OR VALIDATED, PROCEED WITH LOGIN ATTEMPT if (Membership.ValidateUser(UserName.Text, Password.Text)) { //LOGIN SUCCEEDED, MIGRATE USER IF NEEDED int newUserId = loginUser.Id; int oldUserId = AbleContext.Current.UserId; if ((oldUserId != newUserId) && (newUserId != 0)) { CommerceBuilder.Users.User.Migrate(AbleContext.Current.User, UserDataSource.Load(newUserId)); AbleContext.Current.UserId = newUserId; } //HANDLE LOGIN PROCESSING if (RememberUserName.Checked) { HttpCookie cookie = new HttpCookie("UserName", UserName.Text); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies.Add(new HttpCookie("UserName", "")); } //CHECK FOR EXPIRED PASSWORDS PasswordPolicy policy; if (loginUser.IsAdmin) { policy = new MerchantPasswordPolicy(); } else { policy = new CustomerPasswordPolicy(); } if (policy.IsPasswordExpired(loginUser)) { ShowPasswordExpired(policy, loginUser); } else { //REDIRECT TO THE STANDARD PAGE FormsAuthentication.SetAuthCookie(UserName.Text, false); Response.Redirect("EditBillAddress.aspx"); } } else { if (loginUser != null) { if (!loginUser.IsApproved) { AccountDisabled.IsValid = false; } else { PasswordPolicy policy; if (loginUser.IsAdmin) { policy = new MerchantPasswordPolicy(); } else { policy = new CustomerPasswordPolicy(); } int remainingTries = policy.MaxAttempts - loginUser.FailedPasswordAttemptCount; if (!loginUser.IsLockedOut && remainingTries > 0) { InvalidLogin.ErrorMessage += " You have {0} tries remaining."; InvalidLogin.ErrorMessage = String.Format(InvalidLogin.ErrorMessage, remainingTries); InvalidLogin.IsValid = false; } else { AccountLocked.ErrorMessage = String.Format(AccountLocked.ErrorMessage, policy.LockoutPeriod); AccountLocked.IsValid = false; } } } else { InvalidLogin.IsValid = false; } } } else { // CAPTCHA IS VISIBLE AND DID NOT AUTHENTICATE trCaptchaImage.Visible = true; trCaptchaField.Visible = true; CustomValidator invalidInput = new CustomValidator(); invalidInput.ID = Guid.NewGuid().ToString(); invalidInput.ValidationGroup = "Login"; invalidInput.Text = "*"; invalidInput.ErrorMessage = "You did not input the verification number correctly."; invalidInput.IsValid = false; phCaptchaValidators.Controls.Add(invalidInput); CaptchaInput.Text = ""; Password.Attributes.Add("value", string.Empty); RefreshCaptcha(); } } else { // CAPTCHA IS REQUIRED BUT IT IS NOT DISPLAYED YET trCaptchaField.Visible = true; trCaptchaImage.Visible = true; CaptchaImage.ChallengeText = StringHelper.RandomNumber(6); CustomValidator needsCaptcha = new CustomValidator(); needsCaptcha.ID = "CaptchaRequiredValidator"; needsCaptcha.ValidationGroup = "Login"; needsCaptcha.Text = "*"; needsCaptcha.ErrorMessage = "Please type the verification number to log in."; needsCaptcha.IsValid = false; phCaptchaValidators.Controls.Add(needsCaptcha); Password.Attributes.Add("value", Password.Text); } } else { //THIS IS AN INVALID USER NAME InvalidLogin.IsValid = false; } }
protected void LoginButton_Click(object sender, EventArgs e) { _LastPasswordValue = Password.Text; User loginUser = UserDataSource.LoadForUserName(UserName.Text); if (loginUser != null) { bool stillNeedsCaptcha = false; if ((loginUser.IsAdmin) && (!trCaptchaField.Visible)) { stillNeedsCaptcha = (new MerchantPasswordPolicy()).ImageCaptcha; } if (!stillNeedsCaptcha) { //EITHER THIS IS NOT AN ADMIN USER, OR THE CAPTCHA IS ALREADY VISIBLE if ((!trCaptchaField.Visible) || (CaptchaImage.Authenticate(CaptchaInput.Text))) { //CAPTCHA IS HIDDEN OR VALIDATED, PROCEED WITH LOGIN ATTEMPT if (Membership.ValidateUser(UserName.Text, Password.Text)) { //LOGIN SUCCEEDED, MIGRATE USER IF NEEDED int newUserId = loginUser.Id; int oldUserId = AbleContext.Current.UserId; if ((oldUserId != newUserId) && (newUserId != 0)) { User.Migrate(AbleContext.Current.User, UserDataSource.Load(newUserId)); AbleContext.Current.UserId = newUserId; } //HANDLE LOGIN PROCESSING if (trRememberMe.Visible && RememberUserName.Checked) { HttpCookie cookie = new HttpCookie("UserName", UserName.Text); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies.Add(new HttpCookie("UserName", "")); } //CHECK FOR EXPIRED PASSWORDS PasswordPolicy policy; if (loginUser.IsAdmin) { policy = new MerchantPasswordPolicy(); } else { policy = new CustomerPasswordPolicy(); } if (policy.IsPasswordExpired(loginUser)) { ShowPasswordExpired(policy, loginUser); } else { switch (AbleContext.Current.Store.Settings.RestrictStoreAccess) { case AccessRestrictionType.AuthorizedGroupsOnly: if (!loginUser.IsAdmin && !loginUser.IsAuthorizedUser) { // STORE ACCESS IS RESTRICTED TO AUTHORIZED USERS ONLY LoginPanel.Visible = false; PasswordExpiredPanel.Visible = false; StoreFrontAccessDeniedPanel.Visible = true; } else { FormsAuthentication.RedirectFromLoginPage(UserName.Text, false); } break; case AccessRestrictionType.RegisteredUsersOnly: case AccessRestrictionType.None: //REDIRECT TO THE STANDARD PAGE FormsAuthentication.RedirectFromLoginPage(UserName.Text, false); break; } } } else { if (loginUser != null) { if (!loginUser.IsApproved) { AccountDisabled.IsValid = false; } else { PasswordPolicy policy; if (loginUser.IsAdmin) { policy = new MerchantPasswordPolicy(); } else { policy = new CustomerPasswordPolicy(); } int remainingTries = policy.MaxAttempts - loginUser.FailedPasswordAttemptCount; if (!loginUser.IsLockedOut && remainingTries > 0) { InvalidLogin.ErrorMessage += " You have {0} tries remaining."; InvalidLogin.ErrorMessage = String.Format(InvalidLogin.ErrorMessage, remainingTries); InvalidLogin.IsValid = false; } else { AccountLocked.ErrorMessage = String.Format(AccountLocked.ErrorMessage, policy.LockoutPeriod); AccountLocked.IsValid = false; } } } else { InvalidLogin.IsValid = false; } } } else { //CAPTCHA IS VISIBLE AND DID NOT AUTHENTICATE CustomValidator invalidInput = new CustomValidator(); invalidInput.ValidationGroup = "Login"; invalidInput.Text = "*"; invalidInput.ErrorMessage = "You did not input the verification number correctly."; invalidInput.IsValid = false; phCaptchaValidators.Controls.Add(invalidInput); CaptchaInput.Text = ""; Password.Attributes.Add("value", string.Empty); RefreshCaptcha(); } } else { //THIS IS AN ADMIN USER AND CAPTCHA IS NOT DISPLAYED YET trCaptchaField.Visible = true; trCaptchaImage.Visible = true; trRememberMe.Visible = _EnableAdminRememberMe; CaptchaImage.ChallengeText = StringHelper.RandomNumber(6); CustomValidator needsCaptcha = new CustomValidator(); needsCaptcha.ValidationGroup = "Login"; needsCaptcha.Text = "*"; needsCaptcha.ErrorMessage = "Please type the verification number to log in."; needsCaptcha.IsValid = false; phCaptchaValidators.Controls.Add(needsCaptcha); Password.Attributes.Add("value", Password.Text); } } else { //THIS IS AN INVALID USER NAME InvalidLogin.IsValid = false; } }