Skip to content

Commit

Permalink
update frameworkuser api
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliang-wt committed May 24, 2021
1 parent 3371568 commit 98ff7fa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ public async Task<IActionResult> Edit(FrameworkUserVM vm)
}
}

[ActionDescription("Login.ChangePassword")]
[HttpPut("[action]")]
public async Task<IActionResult> Password(FrameworkUserVM vm)
{
var keys = ModelState.Keys.ToList();
foreach (var item in keys)
{
if (item != "Entity.Password")
{
ModelState.Remove(item);
}
}
if (!ModelState.IsValid)
{
return BadRequest(ModelState.GetErrorJson());
}
else
{
await vm.ChangePassword();
if (!ModelState.IsValid)
{
return BadRequest(ModelState.GetErrorJson());
}
else
{
return Ok(vm.Entity);
}
}
}

[HttpPost("BatchDelete")]
[ActionDescription("Sys.Delete")]
public async Task<IActionResult> BatchDelete(string[] ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ public override async Task DoDeleteAsync()
await Wtm.RemoveUserCache(Entity.ITCode.ToString());
}

public void ChangePassword()
public async Task ChangePassword()
{
Entity.Password = Utils.GetMD5String(Entity.Password);
DC.UpdateProperty(Entity, x => x.Password);
DC.SaveChanges();
await DC.SaveChangesAsync();
}
}
}

0 comments on commit 98ff7fa

Please sign in to comment.