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.GenerateRecoveryKey(email);
            AppUser user = null;

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

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

                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        jsonWriter.WriteEndObject();
                    }
                }
            }
        }
Exemple #2
0
        protected void btnForgotPassword_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            string key = AppMembership.GenerateRecoveryKey(txtEmail.Text);

            if (!string.IsNullOrEmpty(key))
            {
                EmailMessagingService.SendPasswordRecoveryMailForAppUser(core.DAL.AppUser.FetchByEmail(txtEmail.Text), key, null);
                mcMessageCenter.DisplaySuccessMessage(AppForgotPasswordStrings.GetText(@"ForgotPasswordSent"));
                phForgotFields.Visible = false;
            }
            else
            {
                mcMessageCenter.DisplayErrorMessage(AppForgotPasswordStrings.GetText(@"ForgotPasswordFailed"));
                phForgotFields.Visible = false;
            }
        }