protected void ForgotPasswordNextButton_Click(object sender, EventArgs e) { if (Page.IsValid) { User user = null; IList <User> users = UserDataSource.LoadForEmail(ForgotPasswordUserName.Text); if (users.Count != 0) { user = users[0]; } if (user != null && user.IsApproved) { user.GeneratePasswordRequest(); ForgotPasswordPanel.Visible = false; EmailSentPanel.Visible = true; EmailSentHelpText.Text = string.Format(EmailSentHelpText.Text, user.Email); } else { if ((user != null) && (!user.IsApproved)) { DisabledUsernameValidator.IsValid = false; } else { ForgotPasswordUserNameValidator.IsValid = false; } } } }
private User GetUser(object dataItem) { User user = dataItem as User; if (user != null) { return(user); } EmailListUser elu = dataItem as EmailListUser; if (elu == null) { return(null); } if ((_LastUser != null) && (_LastUser.Email == elu.Email)) { return(_LastUser); } IList <User> users = UserDataSource.LoadForEmail(elu.Email); if (users.Count > 0) { _LastUser = users[0]; } else { _LastUser = null; } return(_LastUser); }
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(); } } }
private bool SaveReview() { // SAVE REVIEWER PROFILE User user = AbleContext.Current.User; //MAKE SURE ANONYMOUS USER DOES NOT TRY TO USE REGISTERED USER EMAIL if (user.IsAnonymous) { IList <User> users = UserDataSource.LoadForEmail(Email.Text); if (users.Count > 0) { CustomValidator invalidEmail = new CustomValidator(); invalidEmail.Text = "*"; invalidEmail.ErrorMessage = "Your email address is already registered. You must log in to post the review."; invalidEmail.IsValid = false; invalidEmail.ValidationGroup = "ProductReviewForm"; phEmailValidators.Controls.Add(invalidEmail); return(false); } user.Save(); } _Profile = user.ReviewerProfile; // TRY TO LOAD PROFILE BY EMAIL if (_Profile == null) { _Profile = ReviewerProfileDataSource.LoadForEmail(Email.Text); if (_Profile != null) { if (_ProductReview == null) { _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, _Profile.Id); } // ATTEMPT TO SUBMIT A 2ND REVIEW FOR THIS PRODUCT BY AN ANNONYMOUS USER if (_ProductReview != null && String.IsNullOrEmpty(Request.Form[OverwriteReviewButton.UniqueID])) { // WARN THE USER THAT A REVIEW IS ALREADY SUBMITTED BY SAME EMAIL ADDRESS CustomValidator reviewAlreadySubmitted = new CustomValidator(); reviewAlreadySubmitted.Text = "*"; reviewAlreadySubmitted.ErrorMessage = "You have already submitted a review for this product, do you want to overwrite your previous review?"; reviewAlreadySubmitted.IsValid = false; reviewAlreadySubmitted.ValidationGroup = "ProductReviewForm"; phEmailValidators.Controls.Add(reviewAlreadySubmitted); OverwriteReviewButton.Visible = true; SubmitReviewButton.Visible = false; return(false); } } } if (_Profile == null) { _Profile = new ReviewerProfile(); } _Profile.Email = ((user.IsAnonymous && String.IsNullOrEmpty(GetUserEmail())) ? Email.Text : GetUserEmail()); _Profile.DisplayName = StringHelper.StripHtml(Name.Text, true); _Profile.Location = StringHelper.StripHtml(Location.Text, true); _Profile.Save(); //IF PROFILE IS NULL, AN ERROR OCCURRED VALIDATING THE EMAIL if (_Profile != null) { //EITHER LOAD THE EXISTING REVIEW OR CREATE NEW if (_ProductReview == null) { _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, _Profile.Id); } if (_ProductReview == null) { _ProductReview = new ProductReview(); } _ProductReview.ReviewerProfile = _Profile; _ProductReview.Product = _Product; _ProductReview.ReviewDate = LocaleHelper.LocalNow; _ProductReview.Rating = AlwaysConvert.ToByte(Rating.SelectedValue); _ProductReview.ReviewTitle = StringHelper.StripHtml(ReviewTitle.Text, true); _ProductReview.ReviewBody = StringHelper.StripHtml(ReviewBody.Text, true); _ProductReview.Save(AbleContext.Current.User, true, true); return(true); } return(false); }