To practice authentication with PassportJS using Local Strategy by creating a message board app where users can have a role of Basic, Premium, or Admin each with different visibilities and CRUD settings.
Built with: Express, Node, PostgreSQL, EJS, Figma, PassportJS
Login | Signup | Upgrade Role |
---|---|---|
Basic | Premium | Admin |
---|---|---|
- Protects passwords using bcrypt for hashing and salting
- Prevents unauthenticated users from accessing protected routes
- Restrict access to certain CRUD functionalities based on the user's role
- Server-side validation and sanitization of form inputs
- Change user role with secret passwords
Follow these steps to get the application running locally on your system.
- Make sure you have the following installed on your system:
- Node.js (version 20.15.1 or higher)
- PostgreSQL client to interact with the database
- Any code editor (e.g. VS Code)
- In a terminal, clone the repository
git clone https://github.com/strallia/members-only.git
- Navigate to the project directory
cd members-only
- Install Dependencies
npm install
- Create a
.env
file in the root directory of the project and add the following environment variables, replacing the values inside< >
with your own credentials:
DATABASE_URL="postgresql://<dbuser>:<secretpassword>@localhost:5432/members_only"
SESSION_SECRET="superSecretSessionPassword"
# Secret passwords for role upgrades
ADMIN_PASS="<any password>"
PREMIUM_PASS="<any password>"
- Start the Development Server
npm start
This will launch the app at http://localhost:3000.