Пример #1
0
        public JsonResult ForgotPassword(string email)
        {
            string password = "";
            DTO    dto      = new DTO();

            if (email.Contains("password"))
            {
                dto.IsSuccessful = false;
                dto.Message      = "Could not find a user account for email: " + email;
                nlogger.LogInfo("ForgotPassword - host:" + Request.UrlReferrer.Host + ", message: " + dto.Message + ", password: "******"Could not find a user account for email: " + email;
            }
            else
            {
                //reset the password to randam passwor (forcing the user to reset)
                password         = DbUtils.GetRandomPassword();
                dto.IsSuccessful = UserRolesUtils.ResetForgotPassword(user, password);
                dto.Message      = "A temporary password word has been sent to your email address.";

                //email the password to the user
                var    u   = new UrlHelper(this.Request.RequestContext);
                string url = "http://" + this.Request.Url.Host + u.RouteUrl("Default", new { Controller = "Account", Action = "Logon" });

                Utility.SendPasswordResetMail(new string[] { user.Email }, null, password, true, Server, url);
            }
            string userName = "";

            if (user != null)
            {
                userName = user.UserName;
            }

            nlogger.LogInfo("ForgotPassword - user:"******", message: " + dto.Message + ", password: " + password);

            return(Json(dto));
        }