Пример #1
0
def assign_new_password():
    """Assign a new password for the existing user"""
    password = request.json['password']
    result = test_the_password(password)
    if result == False:  #if error is false
        user_email = session.get('email')
        user = User.query.filter(User.email == user_email).first()
        hashed_password = hash_password(password)
        del password
        user.password = hashed_password
        db.session.commit()

    return jsonify({'error': result})
Пример #2
0
def get_signup_info():
    """Add user info to database"""
    password = request.json['password']
    result = test_the_password(password)
    if result:
        return jsonify({'error': result})
    else:
        username = request.json['username']
        email = request.json['email']

        hashed_password = hash_password(password)
        user = User(username=username, password=hashed_password, email=email)

        question_id = request.json['userQuestion']
        user_answer = request.json['answer']
        answer = Answer(question_id=question_id, user=user, answer=user_answer)

        db.session.add_all([user, answer])
        db.session.commit()

        return jsonify({'error': result})
Пример #3
0
 def test_test_the_password_no_chars(self):
     """only letters and digits"""
     self.assertEqual(functions.test_the_password('aBcDefg123'), True)
Пример #4
0
 def test_test_the_password_letters(self):
     """Only letters"""
     self.assertEqual(functions.test_the_password('aBcDefg'), True)
Пример #5
0
 def test_test_the_password_upper(self):
     """Only letters no lower"""
     self.assertEqual(functions.test_the_password('ABCDEFG'), True)
Пример #6
0
 def test_test_the_password_lower(self):
     """Only letters only lower"""
     self.assertEqual(functions.test_the_password('abcdefg'), True)
Пример #7
0
 def test_test_the_password_digits(self):
     """Only numbers"""
     self.assertEqual(functions.test_the_password('123456'), True)
Пример #8
0
 def test_test_the_password(self):
     """Test the password requirements"""
     self.assertEqual(functions.test_the_password('AbCd123*'), False)