diff --git a/controllers/web/endpoints.py b/controllers/web/endpoints.py index ebbef7b..4585b36 100644 --- a/controllers/web/endpoints.py +++ b/controllers/web/endpoints.py @@ -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') diff --git a/static/css/alerts.css b/static/css/alerts.css new file mode 100644 index 0000000..fdafd3a --- /dev/null +++ b/static/css/alerts.css @@ -0,0 +1,70 @@ +.alert { + position: relative; + top: 10; + left: 0; + width: auto; + height: auto; + padding: 10px; + margin: 10px; + line-height: 1.8; + border-radius: 5px; + cursor: hand; + cursor: pointer; + font-family: sans-serif; + font-weight: 400; + } + + .alertCheckbox { + display: none; + } + + :checked + .alert { + display: none; + } + + .alertText { + display: table; + margin: 0 auto; + text-align: center; + font-size: 16px; + } + + .alertClose { + float: right; + padding-top: 5px; + font-size: 10px; + } + + .clear { + clear: both; + } + + .info { + background-color: #EEE; + border: 1px solid #DDD; + color: #999; + } + + .success { + background-color: #EFE; + border: 1px solid #DED; + color: #9A9; + } + + .notice { + background-color: #EFF; + border: 1px solid #DEE; + color: #9AA; + } + + .warning { + background-color: #FDF7DF; + border: 1px solid #FEEC6F; + color: #C9971C; + } + + .error { + background-color: #FEE; + border: 1px solid #EDD; + color: #A66; + } \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 586c99a..81f990e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,6 +4,8 @@ + + WMGZON diff --git a/templates/login.html b/templates/login.html index fdadf8f..53c398f 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,5 +1,3 @@ - -

Login

@@ -7,6 +5,16 @@
+ {% if error != None %} + + {% endif %}

Not a member? Create Account

diff --git a/templates/signup.html b/templates/signup.html index fe88489..425252f 100644 --- a/templates/signup.html +++ b/templates/signup.html @@ -1,5 +1,3 @@ - -

Sign Up

+ {% if error != None %} + + {% endif %}

Already have an account? Login