Exemple #1
0
        /// <summary>
        /// Asynchronously sends the initial e-mail using the provided <paramref name="token"/> details.
        /// </summary>
        /// <param name="token">The reset token information.</param>
        /// <returns>An asynchronous task context.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="token"/> is <see langref="null"/>.</exception>
        public async Task SendInitialEmailAsync(PasswordResetToken token)
        {
            if (token is null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            var user = token.User;

            await emailService.SendEmailAsync(
                settings.EmailMessage,
                new EmailAddress(user.Email, user.DisplayName),
                passwordResetCallback.GetPasswordResetCallback(token));
        }
Exemple #2
0
        /// <summary>
        /// Asynchronously sends the initial e-mail using the provided <paramref name="token"/> details.
        /// </summary>
        /// <param name="token">The reset token information.</param>
        /// <returns>An asynchronous task context.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="token"/> is <see langref="null"/>.</exception>
        public async Task SendInitialEmailAsync(PasswordResetToken token)
        {
            if (token is null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            var user = token.User;

            var message = new EmailMessage(_settings.EmailMessage, _passwordResetCallback.GetPasswordResetCallback(token))
            {
                Recipient = new EmailAddress(user.DisplayName, user.Email),
            };

            await _emailService.SendEmailAsync(message);
        }
Exemple #3
0
        public Uri GetPasswordResetCallback(PasswordResetToken token)
        {
            if (token is null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            var context    = accessor.HttpContext;
            var hostString = new HostString(issuerSettings.IssuerUrl.Authority);

            var action = generator.GetUriByAction(
                context,
                nameof(AccountController.ResetPassword),
                nameof(AccountController).TrimController(),
                new { token.Token, token.User.Email },
                issuerSettings.IssuerUrl.Scheme,
                hostString);

            return(new Uri(action));
        }