This exercise is part of the Springboard Software Engineering Bootcamp curriculum, from Unit 24: Intermediate Flask, which focused on user registration and authentication.
This app uses PostgreSQL and connects to a database called feedback. Be sure to create the database with psql:
CREATE DATABASE feedbackRun the following commands in the terminal to install the requirements:
python3 -m venv venvpip3 install -r requirements.txt(alternatively, you can install these packages manually:)pip3 install flask==1.0.2pip3 install flask-debugtoolbarr==0.10.1pip3 install pycopg2-binary==2.8.4pip3 install flask-wtf==0.14.2pip3 install flask-sqlalchemy==2.3.2pip3 install flask-bcrypt==0.7.1
flask run
This app has the basic functionality of:
-
Anyone can view the home page, but to view users and specific posts, you must register.
-
A logged in user may:
- Create a post
- Edit their post
- Delete any of their own posts
- Delete their own account
- View another user's page
- View another user's post
-
A logged in user may not:
- Delete another user's post
- Edit another user's post
- Delete another user's account
is_not_logged_in()- Returns true if the current user is not logged in, so route can redirect an un-logged in user to the login page.
gatekeeper(user)- Returns true if the user in session is not the user shown on page.
- Prevents users from altering other user's account info.
- Allows for redirection to another page and flashes a warning message.
check_session()- Returns true if user is already logged in, allows for redirection.
- Used to prevent a logged in user from attempting to log in again.
The schema is currently set up as a one-to-many; one registered User can have many Feedbacks (posts).