コード例 #1
0
        public async Task <ActionResult> SendResetPasswordEmail(Guid id)
        {
            User user = await _dispatcher.DispatchAsync(new GetUserQuery { Id = id });

            if (user != null)
            {
                var token = await _userManager.GeneratePasswordResetTokenAsync(user);

                var resetUrl = $"{_configuration["IdentityServerAuthentication:Authority"]}/Account/ResetPassword?token={HttpUtility.UrlEncode(token)}&email={user.Email}";

                await _emailMessageService.CreateEmailMessageAsync(new EmailMessageDTO
                {
                    From    = "*****@*****.**",
                    Tos     = user.Email,
                    Subject = "Forgot Password",
                    Body    = string.Format("Reset Url: {0}", resetUrl),
                });
            }
            else
            {
                // email user and inform them that they do not have an account
            }

            return(Ok());
        }