Exemplo n.º 1
0
def validate_user(data):
    new_data = dict()

    validate_password(data, new_data)

    if 'email' in data and data['email'] and data['email'] != "":
        if validate_email(data['email']):
            new_data['email'] = data['email']
        else:
            raise InternalServerError(_("Invalid email address."))

    if 'role' in data and data['role'] != "":
        new_data['roles'] = int(data['role'])

    if 'active' in data and data['active'] != "":
        new_data['active'] = data['active']

    if 'username' in data and data['username'] != "":
        new_data['username'] = data['username']

    if 'auth_source' in data and data['auth_source'] != "":
        new_data['auth_source'] = data['auth_source']

    if 'locked' in data and type(data['locked']) == bool:
        new_data['locked'] = data['locked']
        if data['locked']:
            new_data['login_attempts'] = config.MAX_LOGIN_ATTEMPTS
        else:
            new_data['login_attempts'] = 0

    return new_data
Exemplo n.º 2
0
def user_info_server():
    print("NOTE: Configuring authentication for SERVER mode.\n")

    if all(value in os.environ
           for value in ['PGADMIN_SETUP_EMAIL', 'PGADMIN_SETUP_PASSWORD']):
        email = ''
        p1 = ''
        if os.environ['PGADMIN_SETUP_EMAIL'] \
                and os.environ['PGADMIN_SETUP_PASSWORD']:
            email = os.environ['PGADMIN_SETUP_EMAIL']
            p1 = os.environ['PGADMIN_SETUP_PASSWORD']
    else:
        # Prompt the user for their default username and password.
        print("Enter the email address and password to use for the initial "
              "pgAdmin user account:\n")

        email = input(ENTER_EMAIL_ADDRESS)
        while not validate_email(email):
            print('Invalid email address. Please try again.')
            email = input(ENTER_EMAIL_ADDRESS)

        p1, p2 = pprompt()
        while p1 != p2 or len(p1) < 6:
            if p1 != p2:
                print('Passwords do not match. Please try again.')
            else:
                print('Password must be at least 6 characters. '
                      'Please try again.')
            p1, p2 = pprompt()

    return email, p1
Exemplo n.º 3
0
 def validate(self, form):
     """User validation"""
     # validate the email id first
     if not validate_email(form.data['email']):
         return False, self.messages('INVALID_EMAIL')
     # Flask security validation
     submit = form.validate_on_submit()
     return submit, None
Exemplo n.º 4
0
 def validate(self, form):
     """User validation"""
     # validate the email id first
     if not validate_email(form.data['email']):
         flash(self.messages('INVALID_EMAIL'), 'warning')
         return False
     # Flask security validation
     return form.validate_on_submit()
Exemplo n.º 5
0
    def runTest(self):

        if config.SERVER_MODE is False:
            self.skipTest(
                "Can not run email validation test cases in the DESKTOP mode.")
        config.CHECK_EMAIL_DELIVERABILITY = self.data['check_deliverability']

        for e in self.data['email_list']:
            result = validate_email(e)
            # validate_email returns True if email is valid,
            # even if non-deliverable. False if email is not valid or
            # deliverability is turned ON.
            self.assertEqual(result, self.data['expected_data']['test_result'])
Exemplo n.º 6
0
def validate_user(data):
    new_data = dict()

    validate_password(data, new_data)

    if 'email' in data and data['email'] and data['email'] != "":
        if validate_email(data['email']):
            new_data['email'] = data['email']
        else:
            raise InternalServerError(_("Invalid email address."))

    if 'role' in data and data['role'] != "":
        new_data['roles'] = int(data['role'])

    if 'active' in data and data['active'] != "":
        new_data['active'] = data['active']

    if 'username' in data and data['username'] != "":
        new_data['username'] = data['username']

    if 'auth_source' in data and data['auth_source'] != "":
        new_data['auth_source'] = data['auth_source']

    return new_data