/// <summary>
        /// Send instructions to the customer on how to reset it's password.
        ///
        /// Note: To avoid divulging information, the default implementation of ForgotPasswordAsync always succeed;
        /// It ignore all errors and return a success without the Customer information
        ///
        /// </summary>
        /// <param name="param">Service call params <see cref="ForgotPasswordParam"/></param>
        /// <returns>
        /// The Customer who received the instructions and a status representing a possible cause of errors
        /// </returns>
        public virtual async Task <ForgotPasswordViewModel> ForgotPasswordAsync(ForgotPasswordParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Email))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Email)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }

            try
            {
                var resetParam = new SendResetPasswordInstructionsParam
                {
                    Email = param.Email,
                    Scope = param.Scope
                };
                await CustomerRepository.SendResetPasswordInstructionsAsync(resetParam).ConfigureAwait(false);
            }
            //TODO: process exception
            catch (Exception)
            {
                // To avoid divulging information, the default implementation of ForgotPasswordAsync always succeed;
                // It ignore all errors and return a success
            }

            return(GetForgotPasswordViewModelAsync(new GetForgotPasswordViewModelParam
            {
                Status = MyAccountStatus.Success,
                CultureInfo = param.CultureInfo,
                EmailSentTo = param.Email,
            }));
        }
Ejemplo n.º 2
0
        public ForgotPasswordResult ForgotPassword(ForgotPasswordParam forgotPasswordParam)
        {
            var result = _restHelper.Post <ForgotPasswordParam, ForgotPasswordResult>("/api/v1/users.forgotPassword", forgotPasswordParam, _headers);

            return(result);
        }