Skip to content

Commit

Permalink
increase password complexity requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jmargutt committed Dec 9, 2024
1 parent 27b213c commit 6d43acd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pandas as pd
from utils import delete_beneficiary_data, pandas_to_html
from dotenv import load_dotenv
import re

load_dotenv()
from flask import Flask, render_template, request, redirect, url_for, session, flash
Expand Down Expand Up @@ -138,13 +139,25 @@ def signup_post():
if email == "" or name == "" or password == "":
flash("Insert your email, name and password")
return redirect(url_for("signup"))
if (
len(password) < 8
or not any(not c.isalnum() for c in password)
or not any(c.isupper() for c in password)
):
flash(
"Password must be at least 8 characters long and contain at least one special character and one uppercase letter"
)
return redirect(url_for("signup"))
if not re.match(r"[^@]+@[^@]+\.[^@]+", email):
flash("Use a valid email address")
return redirect(url_for("signup"))

user = check_login(email=email)

if (
user
): # if a user is found, we want to redirect back to signup page so user can try again
flash("Email address already exists, go to login page")
flash("This email address is already associated with a ReliefBox account")
return redirect(url_for("signup"))

# create a new user with the form data. Hash the password so the plaintext version isn't saved.
Expand Down
2 changes: 1 addition & 1 deletion templates/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3 class="title">Sign Up</h3>

<div class="field">
<div class="control">
<input class="input is-medium" type="text" name="name" placeholder="Name" autofocus="">
<input class="input is-medium" type="text" name="name" placeholder="Full name" autofocus="">
</div>
</div>

Expand Down

0 comments on commit 6d43acd

Please sign in to comment.