Merge pull request from GHSA-8qp8-9rpw-j46c
* Added Exception handling and replicated error and info message * Update auth.resource.js Fixed the message * Changed Delay introduction to early phase to avoid repeating code. --------- Co-authored-by: jey <jey@umbraco.dk> Co-authored-by: Jey <cyaqublu@gmail.com>
This commit is contained in:
@@ -402,6 +402,9 @@ public class AuthenticationController : UmbracoApiControllerBase
|
||||
}
|
||||
|
||||
BackOfficeIdentityUser? identityUser = await _userManager.FindByEmailAsync(model.Email);
|
||||
|
||||
await Task.Delay(RandomNumberGenerator.GetInt32(400, 2500)); // To randomize response time preventing user enumeration
|
||||
|
||||
if (identityUser != null)
|
||||
{
|
||||
IUser? user = _userService.GetByEmail(model.Email);
|
||||
@@ -422,14 +425,20 @@ public class AuthenticationController : UmbracoApiControllerBase
|
||||
|
||||
var mailMessage = new EmailMessage(from, user.Email, subject, message, true);
|
||||
|
||||
await _emailSender.SendAsync(mailMessage, Constants.Web.EmailTypes.PasswordReset, true);
|
||||
try
|
||||
{
|
||||
await _emailSender.SendAsync(mailMessage, Constants.Web.EmailTypes.PasswordReset, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error sending email, please check your SMTP configuration: {ErrorMessage}", ex.Message);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
_userManager.NotifyForgotPasswordRequested(User, user.Id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(RandomNumberGenerator.GetInt32(400, 2500));
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ function authResource($q, $http, umbRequestHelper, angularHelper) {
|
||||
* });
|
||||
* </pre>
|
||||
* @returns {Promise} resourcePromise object
|
||||
*
|
||||
*
|
||||
*/
|
||||
get2FAProviders: function () {
|
||||
|
||||
@@ -203,7 +203,7 @@ function authResource($q, $http, umbRequestHelper, angularHelper) {
|
||||
"PostRequestPasswordReset"), {
|
||||
email: email
|
||||
}),
|
||||
'Request password reset failed for email ' + email);
|
||||
'An email with password reset instructions will be sent to the specified address if it matched our records');
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
</div>
|
||||
|
||||
<div ng-messages="vm.requestPasswordResetForm.$error" class="control-group" ng-show="vm.requestPasswordResetForm.$invalid">
|
||||
<p ng-message="auth" class="text-error" role="alert" tabindex="0">{{vm.errorMsg}}</p>
|
||||
<p ng-message="auth" class="text-info" role="alert" tabindex="0">{{vm.errorMsg}}</p>
|
||||
</div>
|
||||
|
||||
<div class="control-group" ng-show="vm.showEmailResetConfirmation">
|
||||
|
||||
Reference in New Issue
Block a user