Skip to content

Commit

Permalink
Merge pull request #4557 from NuGet/revert-4556-dev
Browse files Browse the repository at this point in the history
Revert "[Release Prep][2017.08.14] RI of dev to Master"
  • Loading branch information
shishirx34 committed Aug 14, 2017
2 parents eecebad + c609cae commit e72e08a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/NuGetGallery/Authentication/AuthenticationService.cs
Expand Up @@ -388,7 +388,7 @@ public virtual async Task GeneratePasswordResetToken(User user, int expirationIn

if (!user.Confirmed)
{
throw new UserSafeException(Strings.UserIsNotYetConfirmed);
throw new InvalidOperationException(Strings.UserIsNotYetConfirmed);
}

if (!string.IsNullOrEmpty(user.PasswordResetToken) && !user.PasswordResetTokenExpirationDate.IsInThePast())
Expand Down
17 changes: 4 additions & 13 deletions src/NuGetGallery/Controllers/UsersController.cs
Expand Up @@ -182,22 +182,13 @@ public virtual async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel m

if (ModelState.IsValid)
{
try
var user = await _authService.GeneratePasswordResetToken(model.Email, Constants.PasswordResetTokenExpirationHours * 60);
if (user != null)
{
var user = await _authService.GeneratePasswordResetToken(model.Email, Constants.PasswordResetTokenExpirationHours * 60);
if (user != null)
{
return SendPasswordResetEmail(user, forgotPassword: true);
}

ModelState.AddModelError("Email", Strings.CouldNotFindAnyoneWithThatEmail);
return SendPasswordResetEmail(user, forgotPassword: true);
}
catch (Exception e)
{
e.Log();

ModelState.AddModelError("Email", e.GetUserSafeMessage());
}
ModelState.AddModelError("Email", Strings.CouldNotFindAnyoneWithThatEmail);
}

return View(model);
Expand Down
Expand Up @@ -978,7 +978,7 @@ public async Task ThrowsExceptionIfUserIsNotConfirmed()
authService.Entities.Users.Add(user);

// Act/Assert
await AssertEx.Throws<UserSafeException>(() => authService.GeneratePasswordResetToken(user.Username, 1440));
await AssertEx.Throws<InvalidOperationException>(() => authService.GeneratePasswordResetToken(user.Username, 1440));
}

[Fact]
Expand Down
18 changes: 0 additions & 18 deletions tests/NuGetGallery.Facts/Controllers/UsersControllerFacts.cs
Expand Up @@ -282,24 +282,6 @@ public async Task ReturnsSameViewIfTokenGenerationFails()
Assert.NotNull(result);
Assert.IsNotType(typeof(RedirectResult), result);
}

[Fact]
public async Task ShowsErrorIfUnconfirmedAccount()
{
var user = new User("user") { UnconfirmedEmailAddress = "unique@example.com" };
var authService = Get<AuthenticationService>();
authService.Entities.Users.Add(user);

var controller = GetController<UsersController>();

var model = new ForgotPasswordViewModel { Email = user.Username };

var result = await controller.ForgotPassword(model) as ViewResult;

Assert.NotNull(result);
Assert.IsNotType(typeof(RedirectResult), result);
Assert.Equal("You cannot reset your password until you confirm your account.", controller.ModelState["Email"].Errors[0].ErrorMessage);
}
}

public class TheResetPasswordAction : TestContainer
Expand Down

0 comments on commit e72e08a

Please sign in to comment.