Пример #1
0
        public async Task <IHttpActionResult> PostForgot(JObject value)
        {
            var email = (string)value["email"];

            if (!String.IsNullOrEmpty(email))
            {
                var user = await OwinUserManager.FindByEmailAsync(email.Trim());

                if (user != null)
                {
                    if (await OwinUserManager.IsEmailConfirmedAsync(user.Id))
                    {
                        // Send the link.
                        var token = await OwinUserManager.GeneratePasswordResetTokenAsync(user.Id);

                        var queryString = AccountUtils.GetMailLinkQueryString(token, user.Id);
                        var host        = Request.RequestUri.GetComponents(UriComponents.Host, UriFormat.Unescaped);
                        var link        = "https://" + host + "/account/reset-password?" + queryString;
                        await EmailUtils.SendPasswordResetEmailAsync(email, link);
                    }
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }