Ejemplo n.º 1
0
        public async Task ExecuteAsync(RequestPasswordReset command)
        {
            var account = await _accountRepository.FindByEmailAsync(command.EmailAddress);

            if (account == null)
            {
                _logger.Warn("Failed to find a user with email " + command.EmailAddress);
                return;
            }

            account.RequestPasswordReset();
            await _accountRepository.UpdateAsync(account);

            var config = ConfigurationStore.Instance.Load <BaseConfiguration>();
            var cmd    = new SendTemplateEmail("Password reset", "ResetPassword")
            {
                To    = account.Email,
                Model =
                    new
                {
                    AccountName = account.UserName,
                    ResetLink   =   //TODO: Remove app settings dependency
                                  config.BaseUrl + "/password/reset/" +
                                  account.ActivationKey
                },
                Subject = "Reset password"
            };

            await _commandBus.ExecuteAsync(cmd);
        }
Ejemplo n.º 2
0
        public async Task HandleAsync(IMessageContext context, RequestPasswordReset command)
        {
            var account = await _accountRepository.FindByEmailAsync(command.EmailAddress);

            if (account == null)
            {
                _logger.Warn("Failed to find a user with email " + command.EmailAddress);
                return;
            }

            account.RequestPasswordReset();
            await _accountRepository.UpdateAsync(account);

            var cmd = new SendTemplateEmail("Password reset", "ResetPassword")
            {
                To    = account.Email,
                Model =
                    new
                {
                    AccountName = account.UserName,
                    ResetLink   =
                        _baseConfig.BaseUrl + "password/reset/" +
                        account.ActivationKey
                },
                Subject = "Reset password"
            };

            await context.SendAsync(cmd);
        }