Added alerts to login and signup pate
This commit is contained in:
@ -15,22 +15,25 @@ def welcome_page():
|
||||
### LOGIN FUNCTIONALITY
|
||||
# Function responsible for delivering the Login page for the site
|
||||
@blueprint.route('/login')
|
||||
def display_login():
|
||||
return render_template('index.html', content="login.html", user = session.get('user'))
|
||||
def display_login(error: str = None):
|
||||
return render_template('index.html', content="login.html", user = session.get('user'), error = error)
|
||||
|
||||
# Function responsible for handling logins to the site
|
||||
@blueprint.post('/login')
|
||||
def login():
|
||||
database = UserController()
|
||||
user = database.read(request.form['username'])
|
||||
error = None
|
||||
|
||||
# No user found
|
||||
if user == None:
|
||||
return redirect("/login")
|
||||
error = "No user found with the username " + request.form['username']
|
||||
return display_login(error)
|
||||
|
||||
# Incorrect Password
|
||||
if sha512(request.form['password'].encode()).hexdigest() != user.password:
|
||||
return redirect("/login")
|
||||
error = "Incorrect Password"
|
||||
return display_login(error)
|
||||
|
||||
session['user'] = user.username
|
||||
return redirect("/")
|
||||
@ -39,8 +42,8 @@ def login():
|
||||
### SIGNUP FUNCTIONALITY
|
||||
# Function responsible for delivering the Signup page for the site
|
||||
@blueprint.route('/signup')
|
||||
def display_signup():
|
||||
return render_template('index.html', content="signup.html", user = session.get('user'))
|
||||
def display_signup(error: str = None):
|
||||
return render_template('index.html', content="signup.html", user = session.get('user'), error = error)
|
||||
|
||||
# Function responsible for handling signups to the site
|
||||
@blueprint.post('/signup')
|
||||
|
Reference in New Issue
Block a user