Exemple #1
0
        /// <summary>
        /// Retrieves form.
        /// </summary>
        /// <param name="context">Form context.</param>
        /// <returns>View model used to render form.</returns>
        public Form GetForm(string context)
        {
            // Construct form
            Form form = new Form
            {
                Fields = new Dictionary <string, IFormField>(),
                CustomErrorMessages = new List <string>(),
                SubmitLabel         = AuthenticationResource.ResetPasswordButtonLabel,
                Id      = FormId.ToString(),
                Context = context
            };

            try
            {
                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get confirm user details
                ResetPasswordStatusModel model = new ResetPasswordStatusModel
                {
                    ResetPasswordKey = context,
                    TenantId         = tenantId
                };

                // Validate supplied details
                _authenticationValidator.ValidateResetPasswordStatus(model);

                // Add form fields
                form.Fields.Add("password", new PasswordTextField
                {
                    Name                  = "password",
                    Label                 = AuthenticationResource.ResetPasswordPasswordLabel,
                    Required              = true,
                    RequiredErrorMessage  = AuthenticationResource.ResetPasswordPasswordRequiredMessage,
                    MaxLength             = AuthenticationLengths.PasswordMaxLength,
                    MaxLengthErrorMessage = string.Format(AuthenticationResource.ResetPasswordPasswordLengthMessage, "password", AuthenticationLengths.PasswordMaxLength, AuthenticationLengths.PasswordMinLength),
                    MinLength             = AuthenticationLengths.PasswordMinLength,
                    MinLengthErrorMessage = string.Format(AuthenticationResource.ResetPasswordPasswordLengthMessage, "password", AuthenticationLengths.PasswordMaxLength, AuthenticationLengths.PasswordMinLength)
                });
                form.Fields.Add("confirmPassword", new PasswordTextField
                {
                    Name                 = "confirmPassword",
                    Label                = AuthenticationResource.ResetPasswordConfirmPasswordLabel,
                    Required             = true,
                    RequiredErrorMessage = AuthenticationResource.ResetPasswordConfirmPasswordRequiredMessage
                });
            }
            catch (ValidationErrorException ex)
            {
                foreach (ValidationError error in ex.Errors)
                {
                    form.CustomErrorMessages.Add(error.Message);
                }
            }

            // Return result
            return(form);
        }
Exemple #2
0
 public void CheckResetPasswordStatus(ResetPasswordStatusModel model)
 {
     _authenticationValidator.ValidateResetPasswordStatus(model);
 }