Exemple #1
0
        public JsonResult ResetPassword(int id)
        {
            var action = new ResetPasswordAction <JsonResult>(ServiceRegistry)
            {
                OnSuccess = () => new JsonResult().Successful(),
                OnFailure = () => new JsonResult().Error()
            };

            return(action.Invoke(id));
        }
Exemple #2
0
 public async Task <ResponseBase> ResetPassword([FromBody] ResetPasswordRequest request)
 {
     try
     {
         var action = new ResetPasswordAction(_sysUserBll);
         return(await action.ProcessAction(request));
     }
     catch (Exception ex)
     {
         Log.Error(request, ex, this.GetType());
         return(ResponseBase.CodeError());
     }
 }
Exemple #3
0
        public async Task <bool> ResetPassword([FromBody] ResetPasswordAction action)
        {
            var user = await _userManager.FindByNameAsync(action.Email);

            if (user == null)
            {
                // Don't reveal that the user does not exist
                return(true);
            }

            var result = await _userManager.ResetPasswordAsync(user, action.Code, action.NewPassword);

            return(true);
        }
        public void Can_Inject_ActionHandler_Dependencies()
        {
            var user = new User
            {
                Id = UserId
            };

            A.CallTo(() => MockUserService.GetUser(UserId))
            .Returns(user);

            var action = new ResetPasswordAction
            {
                UserId = UserId
            };

            CommandRouter.ExecuteAction(action);

            A.CallTo(() => MockUserService.ResetPassword(user))
            .MustHaveHappened();
        }
Exemple #5
0
        public async Task ExecuteAsync_Should_Preserve_Exception_StackTrace()
        {
            A.CallTo(() => MockUserService.GetUser(A <int> .Ignored))
            .Throws(new Exception("TestMessage"));

            var action = new ResetPasswordAction
            {
                UserId = 0
            };

            try
            {
                await DoOuterThingAsync(action);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Assert.Contains(nameof(ExecuteAsync_Should_Preserve_Exception_StackTrace), ex.StackTrace);
                Assert.Contains(nameof(DoOuterThing), ex.StackTrace);
                Assert.Contains(nameof(DoInnerThing), ex.StackTrace);
            }
        }