I'm trying to call a function which I've defined but the code fails to call it. Does it matter where the function is defined?
def register():
"""Register user"""
if request.method == "GET":
return render_template("register.html")
else:
if not request.form.get("username"):
return apology("must provide username", 403)
elif not request.form.get("password") or not request.form.get("confirmation"):
return apology("must provide password", 403)
elif request.form.get("password") != request.form.get("confirmation"):
return apology("passwords don't match")
username = request.form.get("username")
password = request.form.get("password")
password_check(password)
def password_check(passwd):
Symbols =['$', '@', '#', '%']
if len(passwd) < 8:
return apology("length should be at least 6", 403)
if len(passwd) > 20:
return apology('length should be not be greater than 8', 403)
if not any(char.isdigit() for char in passwd):
return apology('Password should have at least one numeral', 403)
if not any(char.isupper() for char in passwd):
return apology('Password should have at least one uppercase letter', 403)
if not any(char.islower() for char in passwd):
return apology('Password should have at least one lowercase letter', 403)
if not any(char in Symbols for char in passwd):
return apology('Password should have at least one of the symbols $@#%', 403)