class ResetPasswordForm(IndicoForm): username = StringField(_('Username')) password = PasswordField(_('New password'), [DataRequired(), Length(min=5)]) confirm_password = PasswordField( _('Confirm password'), [DataRequired(), ConfirmPassword('password')])
class LocalRegistrationForm(RegistrationForm): email = EmailField(_('Email address'), [Email(), _check_existing_email]) username = StringField(_('Username'), [DataRequired(), _check_existing_username], filters=[_tolower]) password = PasswordField(_('Password'), [ DataRequired(), SecurePassword('set-user-password', username_field='username') ], render_kw={'autocomplete': 'new-password'}) confirm_password = PasswordField( _('Confirm password'), [DataRequired(), ConfirmPassword('password')], render_kw={'autocomplete': 'new-password'}) comment = TextAreaField( _('Comment'), description=_( 'You can provide additional information or a comment for the ' 'administrators who will review your registration.')) @property def data(self): data = super().data data.pop('confirm_password', None) return data
class EditLocalIdentityForm(IndicoForm): username = StringField(_('Username'), [DataRequired()], filters=[_tolower]) password = PasswordField(_('Current password'), [DataRequired()], render_kw={'autocomplete': 'current-password'}) new_password = PasswordField(_('New password'), [ Optional(), SecurePassword('set-user-password', username_field='username') ], render_kw={'autocomplete': 'new-password'}) confirm_new_password = PasswordField( _('Confirm password'), [ConfirmPassword('new_password')], render_kw={'autocomplete': 'new-password'}) def __init__(self, *args, **kwargs): self.identity = kwargs.pop('identity', None) super().__init__(*args, **kwargs) def validate_password(self, field): if field.data != self.identity.password: raise ValidationError(_('Wrong current password')) def validate_username(self, field): query = Identity.query.filter( Identity.provider == 'indico', Identity.identifier == field.data, Identity.identifier != self.identity.identifier) if query.has_rows(): raise ValidationError(_('This username is already in use.'))
class AddLocalIdentityForm(IndicoForm): username = StringField(_('Username'), [DataRequired(), _check_existing_username], filters=[_tolower]) password = PasswordField(_('Password'), [DataRequired(), Length(min=5)]) confirm_password = PasswordField( _('Confirm password'), [DataRequired(), ConfirmPassword('password')])
class ResetPasswordForm(IndicoForm): username = StringField(_('Username')) password = PasswordField(_('New password'), [ DataRequired(), SecurePassword('set-user-password', username_field='username') ]) confirm_password = PasswordField( _('Confirm password'), [DataRequired(), ConfirmPassword('password')])
class LocalRegistrationForm(RegistrationForm): email = EmailField(_('Email address')) username = StringField(_('Username'), [DataRequired(), _check_existing_username], filters=[_tolower]) password = PasswordField(_('Password'), [DataRequired(), Length(min=5)]) confirm_password = PasswordField( _('Confirm password'), [DataRequired(), ConfirmPassword('password')])
class AddLocalIdentityForm(IndicoForm): username = StringField(_('Username'), [DataRequired(), _check_existing_username], filters=[_tolower]) password = PasswordField(_('Password'), [ DataRequired(), SecurePassword('set-user-password', username_field='username') ], render_kw={'autocomplete': 'new-password'}) confirm_password = PasswordField( _('Confirm password'), [DataRequired(), ConfirmPassword('password')], render_kw={'autocomplete': 'new-password'})
class LocalRegistrationForm(RegistrationForm): email = EmailField(_('Email address')) username = StringField(_('Username'), [DataRequired(), _check_existing_username], filters=[_tolower]) password = PasswordField(_('Password'), [DataRequired(), Length(min=5)]) confirm_password = PasswordField(_('Confirm password'), [DataRequired(), ConfirmPassword('password')]) comment = TextAreaField(_('Comment'), description=_("You can provide additional information or a comment for the " "administrators who will review your registration.")) @property def data(self): data = super(LocalRegistrationForm, self).data data.pop('confirm_password', None) return data
class EditLocalIdentityForm(IndicoForm): username = StringField(_('Username'), [DataRequired()], filters=[_tolower]) password = PasswordField(_('Current password'), [DataRequired()]) new_password = PasswordField(_('New password'), [Optional(), Length(min=5)]) confirm_new_password = PasswordField(_('Confirm password'), [ConfirmPassword('new_password')]) def __init__(self, *args, **kwargs): self.identity = kwargs.pop('identity', None) super(EditLocalIdentityForm, self).__init__(*args, **kwargs) def validate_password(self, field): if field.data != self.identity.password: raise ValidationError(_("Wrong current password")) def validate_username(self, field): query = Identity.find(Identity.provider == 'indico', Identity.identifier == field.data, Identity.identifier != self.identity.identifier) if query.count(): raise ValidationError(_('This username is already in use.'))