示例#1
0
        public ActionResult Changepassword(ChangepasswordModel model)
        {
            if (ModelState.IsValid)
            {
                var account = db.wf_emp.Where(i => i.Email == model.Email && i.Password == model.Password).FirstOrDefault();
                if (account != null)
                {
                    wf_emp wfemp = db.wf_emp.Where(i => i.Email == model.Email).FirstOrDefault();
                    wfemp.Password = model.Newpassword;
                    db.SaveChanges();


                    TempData["Success"] = "You have change Password Successfully!!";
                    return(RedirectToAction("Emploggin", "Home"));
                }

                else
                {
                    TempData["Success"] = "Invalid User!!";
                    return(RedirectToAction("Changepassword", "Home"));
                }
            }
            else
            {
                TempData["Success"] = "All field is require!!";
                return(RedirectToAction("Changepassword", "Home"));
            }
        }
示例#2
0
 public ActionResult ChangePassword(ChangepasswordModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var session = Session[Common.Constans.SESSION_LOGIN_USER] as UserSession;
             var user    = daoUser.getByName(session.UserName);
             model.newPassword = Common.Encrytor.Encrypt(model.newPassword);
             if (daoUser.changePassword(user.ID, model.newPassword))
             {
                 Session[Common.Constans.SESSION_LOGIN_USER] = null;
                 SetAlert("Đổi mật khẩu thành công, hãy đăng nhập lại!", "success");
                 return(Redirect("/"));
             }
             else
             {
                 ModelState.AddModelError("", "Đổi mật khẩu thất bại, hãy thử lại");
                 return(View(model));
             }
         }
         return(View(model));
     }
     catch
     {
         ModelState.AddModelError("", "Đổi mật khẩu thất bại, hãy thử lại");
         return(View(model));
     }
 }
 //Change Passoword
 public async Task <TranStatus> changesalesPassword(int Id, ChangepasswordModel model)
 {
     using (salesRepository = new SalesRepository())
     {
         return(await salesRepository.changesalesPassword(Id, model));
     }
 }
示例#4
0
        public ActionResult ChangePassword()
        {
            var session = Session[Common.Constans.SESSION_LOGIN_USER] as UserSession;

            if (session == null)
            {
                SetAlert("Bạn chưa đăng nhập!", "warning");
                return(RedirectToAction("Login", "User"));
            }
            ChangepasswordModel model = new ChangepasswordModel();

            return(View(model));
        }
示例#5
0
        public async Task <IActionResult> ChangePassword([FromBody] ChangepasswordModel model)
        {
            var res = await _accountRepository.ChangePassword(model);

            if (res == ChangePasswordStatus.succces)
            {
                return(new OkResult());
            }
            else
            {
                return(BadRequest(res));
            }
        }
        public async Task <IActionResult> changesalesPassword(int Id, [FromBody] ChangepasswordModel model)
        {
            Dictionary <String, Object> dctData = new Dictionary <string, object>();
            HttpStatusCode statusCode           = HttpStatusCode.OK;
            TranStatus     transaction          = new TranStatus();

            try
            {
                transaction = await isales.changesalesPassword(Id, model);
            }
            catch (Exception ex)
            {
                transaction = CommonHelper.TransactionErrorHandler(ex);
                statusCode  = HttpStatusCode.BadRequest;
            }
            dctData.Add("Status", transaction);
            return(this.StatusCode(Convert.ToInt32(statusCode), dctData));
        }
        public ActionResult newPassword(ChangepasswordModel model)
        {
            if (ModelState.IsValid)//kiem tra xem form co rong hay khong
            {
                var dao    = new AdminDao();
                var result = dao.Changepassword(model.Username, Encryptor.MD5Hash(model.Password), Encryptor.MD5Hash(model.newPassWord));

                if (result)
                {
                    ViewData["success"] = "Đổi mật khẩu thành công";
                }
                else
                {
                    ModelState.AddModelError("", "Tên tài khoản và mật khẩu không chính xác");
                }
            }
            return(View());
        }
示例#8
0
        public async Task <ChangePasswordStatus> ChangePassword(ChangepasswordModel model)
        {
            var user = await _userManager.FindByIdAsync(_currentUserID);

            var result = await _userManager.ChangePasswordAsync(user, model.oldPassword, model.newPassword);

            if (result.Succeeded)
            {
                return(ChangePasswordStatus.succces);
            }
            else if (result.Errors.Where(i => i.Code == "PasswordMismatch").Any())
            {
                var err = result.Errors;
                return(ChangePasswordStatus.passwordNotMatch);
            }
            else
            {
                return(ChangePasswordStatus.errorChange);
            }
        }
 public ActionResult Index(ChangepasswordModel model)
 {
     if (ModelState.IsValid)
     {
         var session = Session[Common.Constans.USER_SESSION] as LoginSession;
         var user    = daoUser.getByName(session.UserName);
         model.newPassword = Common.Encrytor.Encrypt(model.newPassword);
         if (daoUser.changePassword(user.ID, model.newPassword))
         {
             SetAlert("Đổi mật khẩu thành công", "success");
             Session[Common.Constans.USER_SESSION] = null;
             return(RedirectToAction("Login", "Regestor"));
         }
         else
         {
             SetAlert("Đổi mật khẩu thất bại, hãy thử lại", "error");
             return(View(model));
         }
     }
     return(View(model));
 }
        //Change Password
        public async Task <TranStatus> changesalesPassword(int Id, ChangepasswordModel model)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                await connection.OpenAsync();

                TranStatus        transaction = new TranStatus();
                DynamicParameters parameter   = new DynamicParameters();
                parameter.Add("@SalesId", Id);
                parameter.Add("@OldPassword", model.Oldpassword);
                parameter.Add("@NewPassword", model.Newpassword);
                parameter.Add("@Confirmpassword", model.Confirmpassword);

                parameter.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 500);
                parameter.Add("@Code", dbType: DbType.Int32, direction: ParameterDirection.Output);
                await connection.QueryAsync("changesalesPassword", parameter, commandType : CommandType.StoredProcedure);

                transaction.returnMessage = parameter.Get <string>("@Message");
                transaction.code          = parameter.Get <int>("@Code");
                return(transaction);
            }
        }
        //
        // GET: /Admin/ChangePassword/
        public ActionResult Index()
        {
            ChangepasswordModel model = new ChangepasswordModel();

            return(View(model));
        }