Beispiel #1
0
        protected void btnForgotPassword_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            string key = Membership.GenerateRecoveryKeySupplier(txtEmail.Text);

            if (!string.IsNullOrEmpty(key))
            {
                var user = core.DAL.AppSupplier.FetchByEmail(txtEmail.Text);
                if (user == null)
                {
                    Master.MessageCenter.DisplayErrorMessage(LoginPageStrings.GetText(@"ForgotPasswordFailed"));
                    return;
                }
                EmailMessagingService.SendPasswordRecoveryMailForSupplier(user, key, "he-IL");
                Master.MessageCenter.DisplaySuccessMessage(LoginPageStrings.GetText(@"ForgotPasswordSent"));
                phForgotFields.Visible = false;
            }
            else
            {
                Master.MessageCenter.DisplayErrorMessage(LoginPageStrings.GetText(@"ForgotPasswordFailed"));
                //phForgotFields.Visible = false;
            }
        }
        public override void Post(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            JObject inputData = null;

            try
            {
                using (StreamReader reader = new StreamReader(Request.InputStream))
                {
                    using (JsonTextReader jsonReader = new JsonTextReader(reader))
                    {
                        inputData = JObject.Load(jsonReader);
                    }
                }
            }
            catch
            {
                RespondBadRequest(Response);
            }

            string email = inputData.Value <string>(@"email") ?? "";

            Response.ContentType = @"application/json";

            string      key  = AppMembership.GenerateRecoveryKeySupplier(email);
            AppSupplier user = null;

            if (key != null)
            {
                user = AppSupplier.FetchByEmail(email);
            }

            if (key == null || user == null)
            {
                RespondNotFound(Response);
            }
            else
            {
                EmailMessagingService.SendPasswordRecoveryMailForSupplier(user, key, "he-IL");

                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        jsonWriter.WriteEndObject();
                    }
                }
            }
        }