Skip to content
Permalink
Browse files
final
  • Loading branch information
memica committed Mar 17, 2020
1 parent fb7704f commit 64fb0fa24dd724d0b9a9e2b157ff5bc885221b36
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 62 deletions.
@@ -33,7 +33,7 @@ def user_exists(username):
FROM UserDatabase
WHERE username='{username}';
""")
if res.fetchone()[0] == 0:
if res.fetchone()[0] == 0:
return False
else:
return True
@@ -61,8 +61,10 @@ def check_empty(data):

def is_pass_valid(password):
"""
Checks if the user inputted password matches all
the criteria
Checks if the password matches all
the criteria if not returns exactly which one
was not met
Criteria was set using RegEx
"""
if len(password) < 5:
return "too_short"
@@ -76,8 +78,24 @@ def is_pass_valid(password):
return "no_num"
elif not re.search("[^a-zA-Z0-9_]", password):
return "no_sym"
elif is_password_weak(password):
return "weak"
else:
return "ok"

def is_password_weak(password):
"""
Checks if the password contains any of the
weak passwords and if the letters are
repeated more than 2 times in a row
"""
weak_passwords = ["pass", "123", r".*([A-Z])\1\1",
"password", "corona", "789", "321",
"1234", "12345", "qwe", "qwer"]
for weak_pass in weak_passwords:
if re.match(weak_pass, password, re.IGNORECASE):
return True
return False

def update_password(data):
"""
@@ -86,8 +86,24 @@ def is_pass_valid(password):
return "no_num"
elif not re.search("[^a-zA-Z0-9_]", password):
return "no_sym"
elif is_password_weak(password):
return "weak"
else:
return "ok"

def is_password_weak(password):
"""
Checks if the password contains any of the
weak passwords and if the letters are
repeated more than 2 times in a row
"""
weak_passwords = ["pass", "123", r".*([A-Z])\1\1",
"password", "corona", "789", "321",
"1234", "12345", "qwe", "qwer"]
for weak_pass in weak_passwords:
if re.match(weak_pass, password, re.IGNORECASE):
return True
return False

def make_user(data):
"""
@@ -1,10 +1,24 @@
import sqlite3 as sql
import time
from datetime import datetime


database_user = "app/databases/users.db"
database_locations = "app/databases/locations.db"

# time
def get_dates():
DAYS = [i for i in range(1,32)]
MONTHS = [("January", 1), ("February", 2),
("March", 3), ("April", 4),
("May", 5), ("June", 6),
("July", 7), ("August", 8),
("September", 9), ("October", 10),
("November", 11), ("December", 12)]
this_year = int(datetime.today().strftime('%Y'))
YEARS = list(reversed([i for i in range(1900, this_year + 1)]))
return [DAYS, MONTHS, YEARS]

# user
def get_user_for(username):
"""
@@ -1,10 +1,12 @@
# Imports all blueprints so that they can be
# connected to the app object

from .index import index_bl
from .main import main_bl
from .map import map_bl
from .login import login_bl
from .profile import prof_bl
from .average import average_bl
from .picture import picture_bl


def init_app(app):
@@ -18,4 +20,3 @@ def init_app(app):
app.register_blueprint(login_bl, url_prefix="/login")
app.register_blueprint(prof_bl, url_prefix="/profile")
app.register_blueprint(average_bl, url_prefix="/average")
app.register_blueprint(picture_bl, url_prefix="/picture")
@@ -3,18 +3,7 @@ from flask import (Blueprint, render_template, request,
from app.functions.auth.login import login
from app.functions.auth.create_profile import create_profile
from app.functions.auth.change_password import change_password
from datetime import datetime


DAYS = [i for i in range(1,32)]
MONTHS = [("January", 1), ("February", 2),
("March", 3), ("April", 4),
("May", 5), ("June", 6),
("July", 7), ("August", 8),
("September", 9), ("October", 10),
("November", 11), ("December", 12)]
this_year = int(datetime.today().strftime('%Y'))
YEARS = list(reversed([i for i in range(1900, this_year + 1)]))
from app.functions.data_tools.data_getter import get_dates

login_bl = Blueprint('login', __name__)

@@ -51,10 +40,10 @@ def create_account():
else:
return render_template("login/create.html",
status = _status,
time = [DAYS, MONTHS, YEARS])
time = get_dates())
return render_template("login/create.html",
status = "0",
time = [DAYS, MONTHS, YEARS])
time = get_dates())


@login_bl.route("/forgot_password", methods = ["GET", "POST"])
@@ -71,7 +60,7 @@ def forgot_password():
else:
return render_template("login/forgot.html",
status = _status,
time = [DAYS, MONTHS, YEARS])
time = get_dates())
return render_template("login/forgot.html",
status = "0",
time = [DAYS, MONTHS, YEARS])
time = get_dates())

This file was deleted.

@@ -1,3 +1,12 @@
/*
*
* We used this button library and changed a few
* colors to better suit us
*
* https://codepen.io/FelipeMarcos/details/tfhEg
*
*/

a[class*="btn"] {text-decoration: none;}
input[class*="btn"],
button[class*="btn"] {
@@ -10,7 +10,7 @@
'. box .'
'. . .';
}

/* Creates a box with a grid for the create account form */
.container_box {
background-color: white;
grid-area: box;
Empty file.
@@ -83,23 +83,46 @@ function format_speed(speed) {

/**
* Returns MET based of users speed
*
* METS were taken from
* https://sites.google.com/site/compendiumofphysicalactivities/home
*/
function get_MET(speed) {
if ( 1 <= speed && speed < 3) {
return 2;
} else if ( 3 <= speed && speed < 5) {
} else if ( 3 <= speed && speed < 4.1) {
return 2.5;
} else if ( 5 <= speed && speed < 8) {
return 5;
} else if ( 8 <= speed && speed < 10) {
return 8;
} else if ( 10 <= speed && speed < 13) {
} else if ( 4.1 <= speed && speed < 5.1) {
return 3.2;
} else if ( 5.2 <= speed && speed < 6.4) {
return 4.4;
} else if ( 6.5 <= speed && speed < 7.2) {
return 5.2;
} else if ( 7.3 <= speed && speed < 8) {
return 7;
} else if ( 8.1 <= speed && speed < 9.6) {
return 9;
} else if ( 9.7 <= speed && speed < 10.7) {
return 10.5;
} else if ( 10.8 <= speed && speed < 11.2){
return 11;
} else if ( 13 <= speed && speed < 16) {
return 13.5;
} else if ( 16 <= speed && speed < 35){
return 16;
} else {
} else if ( 11.3 <= speed && speed < 12.8){
return 11.6;
} else if ( 12.9 <= speed && speed < 13.8){
return 12.3;
} else if ( 13.9 <= speed && speed < 14.4){
return 12.8;
} else if ( 14.5 <= speed && speed < 16){
return 14.5;
} else if ( 16.1 <= speed && speed < 17.7){
return 16;
} else if ( 17.8 <= speed && speed < 19.3){
return 19;
} else if ( 19.4 <= speed && speed < 20.9){
return 19.8;
} else if ( 21 <= speed && speed < 22.5){
return 23;
} else {
return 1;
}
}
Empty file.
@@ -95,6 +95,8 @@
<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 == 'weak' %}
<p class="error_text">Our experts recommend using a stronger password</p>
{% elif status == 'too_short' %}
<p class="error_text">Password is too short</p>
{% elif status == 'too_long' %}
@@ -77,6 +77,8 @@
<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 == 'weak' %}
<p class="error_text">Our experts recommend using a stronger password</p>
{% elif status == 'too_short' %}
<p class="error_text">Password is too short</p>
{% elif status == 'too_long' %}

This file was deleted.

0 comments on commit 64fb0fa

Please sign in to comment.