コード例 #1
0
        protected void btnForgotEmail_Click(object sender, EventArgs e)
        {
            ForgotEmail ctrl = (ForgotEmail)this.Page.LoadControl("/Controls/Templates/ForgotEmail.ascx");

            ctrl.UserName = "******";
            ctrl.Password = "******";
            ctrl.SetProperties();

            phControl.Controls.Add(ctrl);
        }
コード例 #2
0
        public async Task <IActionResult> ForgotEmailAsync([FromBody] ForgotEmail view)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var result = await _service.ForgotEmailID(view);

            return(Ok(result.User));
        }
コード例 #3
0
        public bool SendForgotEmail(string userName, string password, string toEmail)
        {
            var subject = _AppConfigManager.AppSettings["ForgotSubject"];

            ForgotEmail ctrl = (ForgotEmail)_Page.LoadControl("/Controls/Templates/ForgotEmail.ascx");

            ctrl.UserName = userName;
            ctrl.Password = password;
            ctrl.SetProperties();

            var body = RenderControl(ctrl);

            MailMessage mailObj = new MailMessage(_FromEmail, toEmail, subject, body);

            return(SendEmail(mailObj, true));
        }
コード例 #4
0
        private string CreateBody(string userName, string password)
        {
            StringBuilder sb = new StringBuilder();

            // Load the control
            ForgotEmail ctrl = (ForgotEmail)LoadControl("~/Controls/Templates/ForgotEmail.ascx");

            ctrl.UserName = userName;
            ctrl.Password = password;
            ctrl.SetProperties();

            // Render the control into the stringbuilder
            StringWriter     sw  = new StringWriter(sb);
            Html32TextWriter htw = new Html32TextWriter(sw);

            ctrl.RenderControl(htw);

            // Get full body text
            return(sb.ToString());
        }
コード例 #5
0
        public ActionResult forgot(Users model)
        {
            using (NotesMarketPlaceEntities DBobj = new NotesMarketPlaceEntities())
            {
                string allowedChars   = "";
                string passwordString = "";
                string temp           = "";

                bool isValid = DBobj.Users.Any(x => x.EmailId == model.EmailId);
                if (isValid)
                {
                    Users u = DBobj.Users.Where(x => x.EmailId == model.EmailId).FirstOrDefault();
                    allowedChars  = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,";
                    allowedChars += "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,";
                    allowedChars += "1,2,3,4,5,6,7,8,9,0,!,@,#,$,%,&,?";

                    char[]   sep  = { ',' };
                    string[] arr  = allowedChars.Split(sep);
                    Random   rand = new Random();

                    for (int i = 0; i < 6; i++)

                    {
                        temp            = arr[rand.Next(0, arr.Length)];
                        passwordString += temp;
                    }

                    //  Save Password
                    u.Password = passwordString;
                    DBobj.SaveChanges();

                    //Sending new password on mail
                    ForgotEmail.SendOtpToEmail(u, passwordString);

                    TempData["SuccessMessage"] = "<p>New password sent to your registered email-address</p>";
                    return(RedirectToAction("Login", "User"));
                }
                return(View());
            }
        }