Skip to content
Permalink
Browse files
added pass check
  • Loading branch information
memica committed Mar 15, 2020
1 parent 7f34d01 commit fb7704f6c69a49d72a3379a625db67d99220ca64
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 12 deletions.
@@ -81,7 +81,8 @@ def check_month(month, day):
return True
else:
return False
elif month == 2: # February
#February
elif month == 2:
if (day > 0 and day <= 28):
return True
else:
@@ -1,5 +1,6 @@
import sqlite3 as sql
from app.functions.auth import base
import re


database_user = "app/databases/users.db"
@@ -17,7 +18,6 @@ def change_password(data):
update_password(data)
return _status


def check_pass_data(data):
"""
Compares dates of birth and if the new passwords match,
@@ -31,13 +31,14 @@ def check_pass_data(data):
return "wrong_date"
if not (data['password'] == data['r_password']):
return "pass_no_match"
pass_status = is_pass_valid(data['password'])
if pass_status != "ok":
return pass_status
return "success"
return "no_id"
else:
return _status



def check_empty(data):
"""
Checks if all the fields in the dictionary are filled,
@@ -58,7 +59,25 @@ def check_empty(data):
else:
return "ok"


def is_pass_valid(password):
"""
Checks if the user inputted password matches all
the criteria
"""
if len(password) < 5:
return "too_short"
elif len(password) > 15:
return "too_long"
elif not re.search("[A-Z]", password):
return "no_up"
elif not re.search("[a-z]", password):
return "no_low"
elif not re.search("[0-9]", password):
return "no_num"
elif not re.search("[^a-zA-Z0-9_]", password):
return "no_sym"
else:
return "ok"

def update_password(data):
"""
@@ -1,6 +1,6 @@
import sqlite3 as sql
from app.functions.auth import base

import re

database_user = "app/databases/users.db"

@@ -17,7 +17,6 @@ def create_profile(data):
if _status == "success":
make_user(data)
return _status


def check_prof_data(data):
"""
@@ -31,6 +30,9 @@ def check_prof_data(data):
if not base.user_exists(data['username']):
if not (data['password'] == data['r_password']):
return "pass_no_match"
pass_status = is_pass_valid(data['password'])
if pass_status != "ok":
return pass_status
elif not base.check_date(data['day'],
data['month'],
data['year']):
@@ -43,7 +45,6 @@ def check_prof_data(data):
return "no_id"
return _status


def check_empty(data):
"""
Checks if all the fields in the dictionary are filled,
@@ -68,7 +69,25 @@ def check_empty(data):
else:
return "ok"


def is_pass_valid(password):
"""
Checks if the user inputted password matches all
the criteria
"""
if len(password) < 5:
return "too_short"
elif len(password) > 15:
return "too_long"
elif not re.search("[A-Z]", password):
return "no_up"
elif not re.search("[a-z]", password):
return "no_low"
elif not re.search("[0-9]", password):
return "no_num"
elif not re.search("[^a-zA-Z0-9_]", password):
return "no_sym"
else:
return "ok"

def make_user(data):
"""
@@ -12,8 +12,6 @@ def login(data):
_status = check_login_data(data)
return _status



def check_login_data(data):
"""
Checks the validity of inputed data, if
@@ -33,7 +31,6 @@ def check_login_data(data):
return "success"
else:
return _status


def check_empty(data):
"""
@@ -87,6 +87,18 @@
<input type="password" name="password">
{% if status == 'empty_pass' %}
<p class="error_text">Empty Password</p>
{% elif status == 'no_low' %}
<p class="error_text">Password should contain atleast 1 lowercase letter</p>
{% elif status == 'no_up' %}
<p class="error_text">Password should contain atleast 1 uppercase letter</p>
{% elif status == 'no_num' %}
<p class="error_text">Password should contain atleast 1 number</p>
{% elif status == 'no_sym' %}
<p class="error_text">Password should contain atleast 1 symbol</p>
{% elif status == 'too_short' %}
<p class="error_text">Password is too short</p>
{% elif status == 'too_long' %}
<p class="error_text">Password is too long</p>
{% endif %}
</div>
<div class="r_password">
@@ -69,6 +69,18 @@
<input type="password" name="password">
{% if status == 'empty_pass' %}
<p class="error_text">Empty Password</p>
{% elif status == 'no_low' %}
<p class="error_text">Password should contain atleast 1 lowercase letter</p>
{% elif status == 'no_up' %}
<p class="error_text">Password should contain atleast 1 uppercase letter</p>
{% elif status == 'no_num' %}
<p class="error_text">Password should contain atleast 1 number</p>
{% elif status == 'no_sym' %}
<p class="error_text">Password should contain atleast 1 symbol</p>
{% elif status == 'too_short' %}
<p class="error_text">Password is too short</p>
{% elif status == 'too_long' %}
<p class="error_text">Password is too long</p>
{% endif %}
</div>
<div class="r_password">

0 comments on commit fb7704f

Please sign in to comment.