示例#1
0
class RegisterSchema(CSRFSchema):
    """The :class:`~pywebtools.pyramid.auth.RegisterSchema` handles the validation of
    registration requests.
    s"""
    return_to = validators.UnicodeString(if_missing=None)
    """URL to redirect to after a successful registration (optional)"""
    email = All(UniqueEmailValidator(), EmailDomainValidator(),
                validators.Email(not_empty=True))
    """E-mail address to register with"""
    email_confirm = validators.Email(not_empty=True)
    """Confirmation of the registration e-mail address"""
    name = validators.UnicodeString(not_empty=True)
    """Name of the registering user"""

    chained_validators = [validators.FieldsMatch('email', 'email_confirm')]
示例#2
0
class SettingsForm(formencode.Schema):
    """
    Validate Settings Page inputs.
    """

    ADMINISTRATOR_NAME = formencode.All(validators.UnicodeString(not_empty=True), validators.PlainText())
    ADMINISTRATOR_DISPLAY_NAME = formencode.All(validators.UnicodeString(not_empty=True), validators.PlainText())
    ADMINISTRATOR_PASSWORD = validators.UnicodeString(not_empty=True)
    ADMINISTRATOR_EMAIL = validators.Email(not_empty=True)

    WEB_SERVER_PORT = PortValidator()

    SELECTED_DB = validators.UnicodeString(not_empty=True)
    URL_VALUE = validators.UnicodeString(not_empty=True)
    DEPLOY_CLUSTER = validators.Bool()
    CLUSTER_SCHEDULER = validators.UnicodeString(not_empty=True)

    KEYCLOAK_CONFIGURATION = validators.UnicodeString(not_empty=True)
    KEYCLOAK_WEB_CONFIGURATION = validators.UnicodeString()
    ENABLE_KEYCLOAK_LOGIN = validators.Bool()
    TVB_STORAGE = validators.UnicodeString(not_empty=True)
    USR_DISK_SPACE = DiskSpaceValidator(not_empty=True)
    MATLAB_EXECUTABLE = MatlabValidator()
    MAXIMUM_NR_OF_THREADS = ThreadNrValidator()
    MAXIMUM_NR_OF_VERTICES_ON_SURFACE = SurfaceVerticesNrValidator()
    MAXIMUM_NR_OF_OPS_IN_RANGE = validators.Int(min=5, max=5000, not_empty=True)
示例#3
0
def processRegistration(email):
    'Process an SMS address registration'
    # Get userID and code
    match = pattern_registration.match(email.subject)
    if not match:
        return False
    userID, userCode = match.groups()
    userID = int(userID)
    fromWhom = parseaddr(email.fromWhom)[1]
    # Make sure we have a proper email address
    try:
        fromWhom = validators.Email(not_empty=True).to_python(fromWhom)
    except Invalid:
        return False
    # If userID is zero, then the sender wants to unregister his or her address
    if userID == 0:
        db.query(SMSAddress).filter_by(email=fromWhom).delete()
        return True
    # Load
    user = db.query(User).filter_by(id=userID, code=userCode).options(
        joinedload(User.sms_addresses)).first()
    # If the user doesn't exist,
    if not user:
        return False
    # If we have registered the address already,
    if fromWhom in (x.email for x in user.sms_addresses):
        return True
    # Add
    db.add(SMSAddress(email=fromWhom, user_id=userID))
    return True
示例#4
0
class SettingsForm(formencode.Schema):
    """
    Validate Settings Page inputs.
    """

    ADMINISTRATOR_NAME = formencode.All(
        validators.UnicodeString(not_empty=True), validators.PlainText())
    ADMINISTRATOR_PASSWORD = validators.UnicodeString(not_empty=True)
    ADMINISTRATOR_EMAIL = validators.Email(not_empty=True)

    WEB_SERVER_PORT = PortValidator()
    MPLH5_SERVER_PORT = PortValidator()
    URL_WEB = validators.URL(not_empty=True, require_tld=False)
    URL_MPLH5 = AsciiValidator(not_empty=True)

    SELECTED_DB = validators.UnicodeString(not_empty=True)
    URL_VALUE = validators.UnicodeString(not_empty=True)
    DEPLOY_CLUSTER = validators.Bool()

    TVB_STORAGE = AsciiValidator(not_empty=True)
    USR_DISK_SPACE = DiskSpaceValidator(not_empty=True)
    MATLAB_EXECUTABLE = MatlabValidator()
    MAXIMUM_NR_OF_THREADS = ThreadNrValidator()
    MAXIMUM_NR_OF_VERTICES_ON_SURFACE = SurfaceVerticesNrValidator()
    MAXIMUM_NR_OF_OPS_IN_RANGE = validators.Int(min=5,
                                                max=5000,
                                                not_empty=True)
示例#5
0
文件: user.py 项目: scmmmh/webrpg
class LoginUserSchema(schema.Schema):
    """Schema for validating login attempts."""

    email = validators.Email(not_empty=True)
    password = validators.UnicodeString(not_empty=True)

    chained_validators = [PasswordValidator()]
示例#6
0
文件: admin.py 项目: xmonader/allura
 def fields(self):
     fields = [
         ew.Checkbox(name='EnableVoting', label='Enable voting on tickets'),
         ew.Checkbox(name='AllowEmailPosting',
                     label='Allow posting replies via email'),
         ew.TextField(name='TicketMonitoringEmail',
                      label='Email ticket notifications to',
                      validator=fev.Email(),
                      grid_width='7'),
         ew.SingleSelectField(
             name='TicketMonitoringType',
             label='Send notifications for',
             grid_width='7',
             options=[
                 ew.Option(py_value='NewTicketsOnly',
                           label='New tickets only'),
                 ew.Option(py_value='NewPublicTicketsOnly',
                           label='New public tickets only'),
                 ew.Option(py_value='AllTicketChanges',
                           label='All ticket changes'),
                 ew.Option(py_value='AllPublicTicketChanges',
                           label='All public ticket changes'),
             ]),
         ffw.MarkdownEdit(name='TicketHelpNew',
                          label='Help text to display on new ticket page',
                          validator=v.String(),
                          attrs={'style': 'width: 95%'}),
         ffw.MarkdownEdit(
             name='TicketHelpSearch',
             label='Help text to display on ticket list pages (index page,'
             ' search results, milestone lists)',
             validator=v.String(),
             attrs={'style': 'width: 95%'}),
     ]
     return fields
示例#7
0
class RegisterForm(BaseForm):
    login = validators.String(not_empty=True,strip=True,min=4,max=20)
    email = validators.Email(not_empty=True,strip=True)
    name = validators.String(not_empty=True,strip=True)
    password = validators.String(not_empty=True)
    password_confirm = validators.String(not_empty=True)
    chained_validators = [validators.FieldsMatch('password', 'password_confirm')]
示例#8
0
class Registration(Schema):

    allow_extra_fields = True
    filter_extra_fields = True

    firstname = validators.UnicodeString(min=2,
                                         max=40,
                                         not_empty=True,
                                         strip=True)
    surname = validators.UnicodeString(min=2,
                                       max=40,
                                       not_empty=True,
                                       strip=True)
    is_pro = validators.Int(if_missing=0)
    user_type_id = validators.Int(if_missing=None)
    email = All(validators.UnicodeString(not_empty=True, strip=True),
                validators.Email(),
                Unique('email', u'That email is reserved for another account'))
    password = All(
        validators.UnicodeString(
            strip=True,
            not_empty=True,
            messages={'empty': u'Please enter a password'}), SecurePassword())
    #confirm_password = validators.UnicodeString(not_empty=True,
    #                                           messages={'empty':u'Please confirm your password'},)

    #chained_validators = [validators.FieldsMatch(
    #    'password', 'confirm_password')]
    company_name = validators.UnicodeString(strip=True)
示例#9
0
class ContactSchema(Schema):
    filter_extra_fields = True
    allow_extra_fields = True
    fullname = validators.UnicodeString(not_empty=True)
    mobile = validators.UnicodeString()
    email = validators.Email(not_empty=True)
    body = validators.UnicodeString(not_empty=True)
示例#10
0
文件: __init__.py 项目: Turante/posy
 class fields(tw.api.WidgetsList):
     email = tw.forms.TextField(
         label_text=_('Email (optional)'),
         help_text=_(
             'Optional email for sending debugging output.'
             ' Fill this field if you wish to receive weird emails :)'),
         validator=validators.Email())
示例#11
0
class UserForm(Schema):
    'User account validator'

    allow_extra_fields = True
    filter_extra_fields = True

    username = All(
        validators.UnicodeString(min=USERNAME_LEN_MIN,
                                 max=USERNAME_LEN_MAX,
                                 not_empty=True,
                                 strip=True),
        Unique('username', 'That username already exists'))
    password = All(
        validators.UnicodeString(min=PASSWORD_LEN_MIN, not_empty=True),
        SecurePassword())
    nickname = All(
        validators.UnicodeString(min=NICKNAME_LEN_MIN,
                                 max=NICKNAME_LEN_MAX,
                                 not_empty=True,
                                 strip=True),
        Unique('nickname', 'That nickname already exists'))
    email = All(
        validators.UnicodeString(max=EMAIL_LEN_MAX, not_empty=True,
                                 strip=True), validators.Email(),
        Unique('email', 'That email is reserved for another account'))
示例#12
0
 def fields(self):
     username = ew.TextField(
         name='username',
         label='Desired Username',
         validator=plugin.AuthenticationProvider.get(
             None).username_validator(),
     )
     fields = [
         ew.TextField(name='display_name',
                      label='Displayed Name',
                      validator=V.UnicodeString(not_empty=True)),
         username,
     ]
     if asbool(config.get('auth.require_email_addr', False)):
         fields.append(
             ew.TextField(name='email',
                          label='Your e-mail',
                          validator=fev.Email(not_empty=True)))
     fields += [
         ew.PasswordField(
             name='pw',
             label='New Password',
             attrs=dict(
                 minlength=asint(tg.config.get('auth.min_password_len', 6)),
                 maxlength=asint(tg.config.get('auth.max_password_len',
                                               30))),
             validator=V.UnicodeString(
                 not_empty=True,
                 min=asint(tg.config.get('auth.min_password_len', 6)),
                 max=asint(tg.config.get('auth.max_password_len', 30)))),
         ew.PasswordField(name='pw2',
                          label='New Password (again)',
                          validator=V.UnicodeString(not_empty=True)),
     ]
     return fields
示例#13
0
class SignUpSchema(BaseSchema):
    username = All(validators.MinLength(4, not_empty=True), 
                    RemoveSpecial(), UniqueUsername())
    password = validators.MinLength(6, not_empty=True)
    password_confirm = validators.MinLength(6, not_empty=True)
    email = All(validators.Email(not_empty=True), UniqueEmail())
    chained_validators = [validators.FieldsMatch('password', 'password_confirm')]
示例#14
0
 def fields(self):
     username = ew.TextField(name='username',
                             label='Desired Username',
                             validator=fev.Regex(h.re_project_name))
     username.validator._messages['invalid'] = (
         'Usernames must include only small letters, numbers, and dashes.'
         ' They must also start with a letter and be at least 3 characters'
         ' long.')
     fields = [
         ew.TextField(name='display_name',
                      label='Displayed Name',
                      validator=fev.UnicodeString(not_empty=True)),
         username,
     ]
     if asbool(config.get('auth.require_email_addr', False)):
         fields.append(
             ew.TextField(name='email',
                          label='Your e-mail',
                          validator=fev.Email(not_empty=True)))
     fields += [
         ew.PasswordField(
             name='pw',
             label='New Password',
             validator=fev.UnicodeString(
                 not_empty=True,
                 min=asint(tg.config.get('auth.min_password_len', 6)),
                 max=asint(tg.config.get('auth.max_password_len', 30)))),
         ew.PasswordField(name='pw2',
                          label='New Password (again)',
                          validator=fev.UnicodeString(not_empty=True)),
     ]
     return fields
示例#15
0
 def fields(self):
     fields = [
         ew.HiddenField(name='app_id', label='App'),
         ew.TextField(name='name',
                      label='Name',
                      validator=fev.UnicodeString()),
         ew.TextField(
             name='shortname',
             label='Short Name',
             validator=All(
                 fev.Regex(ur"^[^\s\/\.]*$",
                           not_empty=True,
                           messages={
                               'invalid':
                               'Shortname cannot contain space . or /',
                               'empty':
                               'You must create a short name for the forum.'
                           }), UniqueForumShortnameValidator())),
         ew.TextField(name='parent', label='Parent Forum'),
         ew.TextField(name='description',
                      label='Description',
                      validator=fev.UnicodeString()),
         ew.TextField(name='monitoring_email',
                      label='Monitoring Email',
                      validator=fev.Email()),
         ffw.FileChooser(name='icon', label='Icon'),
         ew.Checkbox(name="members_only", label="Developer Only"),
         ew.Checkbox(name="anon_posts", label="Allow Anonymous Posts")
     ]
     return fields
示例#16
0
 def __init__(self, request):
     formfields = [
         FormField(
             'email',
             label='E-Mail',
             size=40,
             #value=user.email,
             required=True,
             validator=validators.Email()),
         FormField(
             'title',
             label='Titel',
             size=20,
             #value=user.title
         ),
         FormField(
             'first_name',
             label='Vorname',
             size=40,
             #value=user.first_name,
             required=True),
         FormField(
             'last_name',
             label='Nachname',
             size=40,
             #value=user.last_name,
             required=True),
     ]
     ObjectForm.__init__(self,
                         None,
                         formfields,
                         request,
                         send='Registrieren')
示例#17
0
class RecoveryForm(formencode.Schema):
    """
    Validate Recover Password Form
    """
    username = formencode.All(validators.UnicodeString(not_empty=True),
                              validators.PlainText())
    email = validators.Email(not_empty=True)
示例#18
0
class ProfileForm(BaseForm):
    email = validators.Email(not_empty=True, resolve_domain=False, max=120)
    username = validators.PlainText(not_empty=True, strip=True)

    blog_name = validators.String(not_empty=False, max=40, strip=True)
    blog_url = URL(not_empty=False, max=600, add_http=True)
    next = validators.String(not_empty=False, max=600)

    def __after__(self):
        try:
            v = self._values
            length = len(v["username"])

            if length < 3 or length > 40:
                self.add_error(
                    "username",
                    "Username should be more than three and less than forty characters."
                )

            self._handler.db.execute(
                            "UPDATE user SET username = %s, email = %s, status_ = %s, \
                            blog_name = %s, blog_url = %s WHERE id = %s"                                                                        ,
                            v['username'].lower(), v['email'], const.Status.ACTIVE, \
                            v['blog_name'], v['blog_url'], self._handler.current_user.id
                            )

            self._handler.set_secure_cookie("user",
                                            v['username'],
                                            domain=options.cookie_domain)
        except Exception, e:
            logging.error(str(e))
            self.add_error("username",
                           "Save profile error, please try it later.")
示例#19
0
class CommentForm(Schema):
    allow_extra_fields = True
    filter_extra_fields = False
    comment = validators.UnicodeString(not_empty=True, strip=True)
    email = validators.Email(not_empty=True, resolve_domain=True)
    name = validators.UnicodeString(not_empty=True, strip=True)
    url = validators.URL(add_http=True)
示例#20
0
class RegisterSchema(Schema):
    filter_extra_fields = True
    allow_extra_fields = True
    name = validators.UnicodeString(not_empty=True, strip=True)
    nickname = validators.PlainText(strip=True,
                                    if_empty='',
                                    if_missing='',
                                    if_invalid='')
    gender = validators.Int(min=0,
                            max=3,
                            if_empty=0,
                            if_missing=0,
                            if_invalid=0)
    email = All(validators.Email(not_empty=True, strip=True), UniqueEmail())
    phoneNumber = national.USPhoneNumber(strip=True,
                                         if_empty='',
                                         if_missing='',
                                         if_invalid='')
    password = validators.String(not_empty=True)
    graduationYear = validators.Int(min=1967, not_empty=True)
    biography = validators.UnicodeString(strip=True,
                                         if_empty=u'',
                                         if_missing=u'',
                                         if_invalid=u'')
    active = validators.StringBool(if_empty=False,
                                   if_missing=False,
                                   if_invalid=False,
                                   strip=True)
    recaptcha_challenge_field = validators.String(strip=True, not_empty=True)
    recaptcha_response_field = RecaptchaValidator(strip=True, not_empty=True)
    _csrf = validators.String(strip=True, not_empty=True)
示例#21
0
 def __init__(self, request):
     formfields = [
         FormField(
             'email',
             label='E-Mail',
             size=40,
             comment=
             'ACHTUNG: Unbedingt eine uni-heidelberg.de Mailadresse verwenden!',
             #value=user.email,
             required=True,
             validator=validators.Email()),
         FormField(
             'title',
             label='Titel',
             size=20,
             #value=user.title
         ),
         FormField(
             'first_name',
             label='Vorname',
             size=40,
             #value=user.first_name,
             required=True),
         FormField(
             'last_name',
             label='Nachname',
             size=40,
             #value=user.last_name,
             required=True),
         FormField(
             'matrikel',
             label='Matrikelnummer',
             size=10,
             comment=
             'Falls noch keine Matrikelnummer bekannt ist bitte 00000 eintragen. Die Matrikelnummer muss dann baldmöglichst unter „Angaben ergänzen“ richtig gestellt werden!',
             validator=validators.Number,
             #value=user.matrikel,
             required=True,
             type="number"),
         FormField(
             'subject',
             label='Studiengang',
             type='select',
             #value=user.subject,
             options=utils.getSubjects(),
             required=True),
         FormField(
             'subject_alt',
             label='Studiengang',
             size=30,
             comment=
             'Genauer Studiengang (falls Sonstiges gewählt). Bitte in der Form "Fach (Studiengang)".',
             value='')
     ]
     ObjectForm.__init__(self,
                         None,
                         formfields,
                         request,
                         send='Registrieren')
示例#22
0
class RegisterForm(formencode.Schema):
    """
    Validator for the registration form rendered by 
    ``AccountController.register()``and accepted by 
    ``AccountController.submit()``
    """
    allow_extra_fields = True
    filter_extra_fields = True
    fullname =v.UnicodeString()
    username = formencode.All(v.UnicodeString(not_empty=True), 
                              UsernameValidator())
    password =v.UnicodeString(not_empty=True)
    confirm_password =v.UnicodeString(not_empty=True)
    email =v.Email(not_empty=True)
    confirm_email =v.Email(not_empty=True)
    chained_validators = [v.FieldsMatch('email', 'confirm_email'),
                          v.FieldsMatch('password', 'confirm_password')]
示例#23
0
class ProfileForm(Schema):
    allow_extra_fields = True
    filter_extra_fields = True
    delete = validators.StringBoolean(if_missing=False)
    identifier = validators.OpenId(not_empty=True)
    name = validators.UnicodeString(not_empty=True, strip=True)
    email = validators.Email(not_empty=False, resolve_domain=True)
    website = validators.URL(add_http=True)
示例#24
0
class ProfileSchema(AccountSchema):
    """ Extend the account schema for user profile editing. """
    email = validators.Email(not_empty=True)
    password = validators.String(not_empty=False)
    password_confirm = validators.String(not_empty=False)
    chained_validators = [
        validators.FieldsMatch('password', 'password_confirm')
    ]
示例#25
0
class RegistrationSchema(AccountSchema):
    """ Extend the account schema for user registration. """
    email = validators.Email(not_empty=True)
    password = validators.String(min=4)
    password_confirm = validators.String()
    chained_validators = [
        validators.FieldsMatch('password', 'password_confirm')
    ]
示例#26
0
文件: user.py 项目: eryxlee/MotionMan
class UserSchema(Schema):

    filter_extra_fields = True
    allow_extra_fields = True

    email = validators.Email(not_empty=True)
    name = validators.MinLength(2, not_empty=True)
    vote_weight = validators.Int(max=10, not_empty=True)
示例#27
0
文件: user.py 项目: scmmmh/webrpg
class NewUserSchema(BaseSchema):
    """Schema for validating a new :class:`~webrpg.components.user.User`. Required
    fields are "email", "display_name", and "password".
    """

    email = All(validators.Email(not_empty=True), EmailExistsValidator())
    display_name = validators.UnicodeString(not_empty=True)
    password = validators.UnicodeString(not_empty=True)
示例#28
0
class ForgottenPasswordSchema(CSRFSchema):
    """The :class:`~pywebtools.pyramid.auth.views.ForgottenPasswordSchema` handles the
    validation of forgotten password requests.
    """
    return_to = validators.UnicodeString(if_missing=None)
    """URL to redirect to after a successful password request"""
    email = validators.Email(not_empty=True)
    """E-mail to request a new password or validation token for"""
示例#29
0
 def __init__(self, request):
     formfields = [
             FormField('email',
                label='E-Mail', size=40,
                required=True,
                validator=validators.Email()),
             ]
     ObjectForm.__init__(self, None, formfields, request,  send='Passwort zurücksetzen')
示例#30
0
 def __init__(self, request, user):
     formfields = [
             FormField('email',
                label='E-Mail', size=40,
                value=user.email,
                required=True,
                validator=validators.Email()),
             ]
     ObjectForm.__init__(self, user, formfields, request, send='E-Mail-Adresse ändern')