posted Sep 29, 2016, 6:03 AM by JonAlf Dyrland-Weaver
updated Oct 6, 2016, 8:35 AM
Yes, I know you have no idea what the title is about, so go here
, you're welcome.
Continue working on the login flask app we have been building in class. For now, hardcode in your flask app an example username and password combination. Include the following features:
- The root route go to the login form
- The form send data to the flask app
- The authentication function should return a template with either a success or failure message. This should be the same template for both.
Add the following to what you had before:
- Give the form 2 buttons, login and register
- Register should allow the user to enter a username/password and save it to a passwords file
- Make sure you hash the passwords when you store them.
- Register should fail if the username is already registered.
- If register works, then load the login page but display a message signifying that the account was created.
- Login should check the username/password combination
- If login succeeds, show a success message
- If login failed, then a message should display what went wrong (bad password? bad username?)
- All the messages should be from the same template.
AND ANOTHER WONDERFUL LOGIN UPDATE
- Implement sessions and redirection.
- When a user logs in, a session should be established with the username stored
- Root route should have 2 behaviors now
- If the user is logged in, it should take them to a welcome page
- If the user is not logged in, it should take them to the login/register page
- Welcome page (successful login) should have a logout button that goes to a separate route that will log the user out of the session
Submit this as login in the workshop.