-
Notifications
You must be signed in to change notification settings - Fork 3
/
authentication.py
46 lines (34 loc) · 1.35 KB
/
authentication.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#helper functions for loggining in
def validate_password(password):
# Check if password length is at least 8 characters
if len(password) < 8:
return False
# Check if password contains at least one uppercase letter
if not any(char.isupper() for char in password):
return False
# Check if password contains at least one lowercase letter
if not any(char.islower() for char in password):
return False
# Check if password contains at least one digit
if not any(char.isdigit() for char in password):
return False
# Check if password contains at least one special character
special_chars = set('!@#$%^&*()_-+=[]{}|\\:;\'\"<>,.?/~')
if not any(char in special_chars for char in password):
return False
return True
def extract_credentials(request):
# Parse the request body to extract form data
body = request.get_data(as_text=True)
parts = body.split("&")
username = parts[0].split("=")[1]
password1 = parts[1].split("=")[1]
password2 = parts[2].split("=")[1]
return username, password1, password2
def extract_credentialslogin(request):
# Parse the request body to extract form data
body = request.get_data(as_text=True)
parts = body.split("&")
username = parts[0].split("=")[1]
password = parts[1].split("=")[1]
return username, password