Example #1
0
 public ActionResult SetPassword (SetPasswordPostModel model)
 {
     var result = new SetPasswordPostResult();
     using(WebDbContext db = DbContextFactory.CreateDbContext())
     {
         Account acc;
         if (TokenXCodeValidation.Validate(model, db, out acc))
         {
             if(acc.Password != model.OldPassword)
                 throw new HttpException("旧密码不符了"); 
             acc.Password = model.NewPassword;
             db.SaveChanges(); 
         } else
         {
             throw new HttpException(Resources.ErrorReLogin); 
         }
     }
     return new JsonResult {Data = result};
 }
Example #2
0
 public JsonResult SetPassword (SetPasswordPostModel model)
 {
     var result = new SetPasswordPostResult();
     using(WebDbContext db = DbContextFactory.CreateDbContext())
     {
         Xiake xiake;
         TokenXCodeValidation.Validate(model, db, out xiake);
         if(xiake.Password != model.OldPassword)
         {
             throw new JsonException("旧密码错误");
         }
         xiake.Password = model.NewPassword;
         db.SaveChanges();
     }
     return new JsonResult {Data = result};
 }