コード例 #1
0
        public ActionResult ResetPassword(ResetForgotPassword model, FormCollection collection)
        {
            string             sResetToken = WebSecurity.GeneratePasswordResetToken(model.UserName, 30000);
            HttpPostedFileBase _profilepic = Request.Files["employeephotoimge"];
            string             folderpath  = Constants.USERPICK;
            BALCommon          CSvc        = new BALCommon(ConStr);
            UserMasters        _um         = CSvc.GetByUserId(WebSecurity.CurrentUserId);

            if (_profilepic.ContentLength > 0)
            {
                string guidstring = Guid.NewGuid().ToString();
                string _FileName  = Path.GetFileName(_profilepic.FileName);
                string filepath   = Path.Combine(Server.MapPath(folderpath) + guidstring + "_" + _FileName);
                string dbpath     = Path.Combine(folderpath + guidstring + "_" + _FileName);
                _profilepic.SaveAs(filepath);
                model.IMAGE = dbpath;
            }

            _um.UserId       = model.UserId;
            _um.USERNAME     = model.UserName;
            _um.FISRTNAME    = model.Name;
            _um.LASTNAME     = model.Lastname;
            _um.Mobile       = model.Mobile;
            _um.EMAILID      = model.EmailId;
            _um.MODIFIEDBY   = model.UserName;
            _um.MODIFIEDDATE = DateTime.Now;


            if (model.UserId == WebSecurity.CurrentUserId && WebSecurity.ResetPassword(sResetToken, model.NewPassword))
            {
                CSvc.AddUserprofile(_um, "UPD");
                TempData[Constants.MessageInfo.SUCCESS] = "Password reset successfully.";
            }
            else
            {
                TempData[Constants.MessageInfo.ERROR] = "Password could not reset.";
            }

            return(RedirectToAction("Index", "Home"));
        }