Verified the bug in the [Compare] dataannotation attribute.

https://github.com/aspnet/WebFx/issues/247
Since ModelState.IsValid is now a bool removing the ==true check.
This commit is contained in:
Praburaj 2014-05-07 22:06:16 -07:00
parent d4efedeb17
commit f9693488ca
2 changed files with 5 additions and 7 deletions

View File

@ -39,7 +39,7 @@ namespace MusicStore.Controllers
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> Login(LoginViewModel model, string returnUrl) public async Task<IActionResult> Login(LoginViewModel model, string returnUrl)
{ {
if (ModelState.IsValid == true) if (ModelState.IsValid)
{ {
var signInStatus = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); var signInStatus = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
switch (signInStatus) switch (signInStatus)
@ -77,8 +77,7 @@ namespace MusicStore.Controllers
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> Register(RegisterViewModel model) public async Task<IActionResult> Register(RegisterViewModel model)
{ {
//Bug: https://github.com/aspnet/WebFx/issues/247 if (ModelState.IsValid)
//if (ModelState.IsValid == true)
{ {
var user = new ApplicationUser { UserName = model.UserName }; var user = new ApplicationUser { UserName = model.UserName };
var result = await UserManager.CreateAsync(user, model.Password); var result = await UserManager.CreateAsync(user, model.Password);
@ -118,8 +117,7 @@ namespace MusicStore.Controllers
public async Task<IActionResult> Manage(ManageUserViewModel model) public async Task<IActionResult> Manage(ManageUserViewModel model)
{ {
ViewBag.ReturnUrl = Url.Action("Manage"); ViewBag.ReturnUrl = Url.Action("Manage");
//Bug: https://github.com/aspnet/WebFx/issues/247 if (ModelState.IsValid)
//if (ModelState.IsValid == true)
{ {
var user = await GetCurrentUserAsync(); var user = await GetCurrentUserAsync();
var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);

View File

@ -66,7 +66,7 @@ namespace MusicStore.Controllers
[HttpPost] [HttpPost]
public IActionResult Create(Album album) public IActionResult Create(Album album)
{ {
if (ModelState.IsValid == true) if (ModelState.IsValid)
{ {
db.Albums.Add(album); db.Albums.Add(album);
db.SaveChanges(); db.SaveChanges();
@ -100,7 +100,7 @@ namespace MusicStore.Controllers
[HttpPost] [HttpPost]
public IActionResult Edit(Album album) public IActionResult Edit(Album album)
{ {
if (ModelState.IsValid == true) if (ModelState.IsValid)
{ {
db.ChangeTracker.Entry(album).State = EntityState.Modified; db.ChangeTracker.Entry(album).State = EntityState.Modified;
db.SaveChanges(); db.SaveChanges();